I am using debian 12 and qt 6.5.2. Qt installed in external HDD inside my laptop. I want to use qtnetwork module in qml file. So, I have added network in .pro and it works fine(successfully included in cpp header file without any error) but problem when try to include in qml file.Give this eror message: "QML module not found(QtNetwork)". Here is my code:
QML File:
import QtQuick 2.15 import Qt.Nework //problem arise here import QtQuick.Controls
Rectangle {
id: root
height: parent
width: parent
// properties
property string targetAddress: "127.0.0.1"
property int startPort: 1
property int endPort: 65535
}
.pro file QT += core gui network quick quickcontrols2 quickwidgets qml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
portscanner.cpp
HEADERS += \
portscanner.h
FORMS += \
portscanner.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
resources.qrc
DISTFILES +=
`
**main.cpp file**
`#include "portscanner.h"
#include <QQuickWindow>
#include <QApplication>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
QApplication a(argc, argv);
PortScanner w;
w.show();
return a.exec();
}
and implementation file #include "portscanner.h" #include "ui_portscanner.h"
PortScanner::PortScanner(QWidget *parent)
: QWidget(parent)
, ui(new Ui::PortScanner)
{
ui->setupUi(this);
// show qml file
ui->qml_viewer->setSource (QUrl(QStringLiteral("qrc:/qml/SuperFastDownloadManagerGui.qml")));
}
PortScanner::~PortScanner()
{
delete ui;
}
I found this https://forum.qt.io/topic/143956/module-qtnetwork-is-not-installed but not work.