Solved Where is my QML?
-
Hi,
I have very simple QML test app. It looks like this:
Main ( no changes ):
#include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
QML:
import QtQuick 2.0 import QtQuick.Controls 2.11 Item { Button { text: "Ok" } }
MainWindow.cpp:
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); widget = new QQuickWidget(this); widget->setSource((QUrl(QStringLiteral("qrc:/test.qml")))); widget->move(10,10); widget->resize(400,400); } MainWindow::~MainWindow() { delete ui; }
When I run this app from QTCreator, eveything is ok ( I see Button "ok" ). When I run this application from my folder on Desktop I don't see a Button ( my app of course is running ).
My folder on desktop with qmlTest app:
So I think I need other files and copy it to my folder on Desktop. But which one?
-
@qwe3
use the https://doc.qt.io/qt-5/windows-deployment.html toolkeep an eye on the --qmldir argument, that is important, when you deploy a qml app or a widget app that uses qml parts
-
This post is deleted! -
@VRonin But I see that Button when I run it on QT Creator
EDIT: Please a link
EDIT2: My goal was to have QT Widgets app with QML
-
@qwe3
use the https://doc.qt.io/qt-5/windows-deployment.html toolkeep an eye on the --qmldir argument, that is important, when you deploy a qml app or a widget app that uses qml parts
-
@J-Hilk Thank you, but maybe there is a simple solution?
I check examples:
.....\Examples\Qt-5.15.1\quick\quickwidgets
and when I move that .exe to folder to the Desktop - I still don't see qml. So:qrc:quickwidget/rotatingsquaretab.qml
is not a proper path? -
@qwe3 said in Where is my QML?:
Thank you, but maybe there is a simple solution?
thats the simplest solution you can find, literally one command in the command line terminal
-
@J-Hilk I see that you are a person, who understand my problem. I don't undesrtand why in QT Creator it works and on the desktop not.
And I would like to have solution, where I don't need extra tools. I would like to solve this using only my app's source code.
-
@J-Hilk My problem is not a qrc: I change qrc to QUrl::fromLocalFile. Qt Creator - works, run app from Desktop - not works. So maybe some dll?
-
@qwe3 you need to deploy your application, if you want to use it outside of qt creator, simple as that
to deploy it you can either copy and past by hand everything needed, or you let the windeployqt tool do that job for you, like I suggested