How to use "Qt Desktop Components" on Qt5
-
I am not sure how to build the Qt Desktop Components. It says on the "wiki":http://qt-project.org/wiki/QtDesktopComponents that you should "qmake" and then "make install". I opened the Qt5 command line and ran qmake; all fine. When I run "make install" it says it does not recognize the command. What do I need to do/set/install to make the desktop components.
-
You are using Windows, right? There is no "make" on Windows, you need to use nmake/ jom (if your compiler is MSVC) or mingw-make if you are using MinGW.
I'm not sure Desktop Components are ready for Qt5 and windows anyway. Most Qt developers work on linux.
-
Hello,
Does someone has tried to use QtDesktopComponents on windows?
Thanks!
-
This project is now integrated into mainline Qt. You can get it by simply downloading Qt 5.1. Search the documentation for QtQuick.Controls module to learn more.
-
Hi,
I am unsure how to create a hybrid Cpp + QtQuick 2 + QtQuck Controls project.In QtCreator 2.8 there are two project templates of interest: A) "QtQuick 2 UI with Controls" and B) "QtQuick 2 Application - (Built-in types)".
A) This type of projcect can consist only of QML files, so no C++ here AFAIK.
B). Consists of a main.cpp, main.qml as well as a qtquick2applicationviewer[.h/.cpp] file.
In B) Doing an 'import Qt.QuickControls 1.0' inside main.qml is not enough, since according to the documentation found here: http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrols/qtquickcontrols-overview.html we ought to change the 'main.cpp' file to support them.
Changing my main.cpp file, from:
@#include <QApplication>
#include <QQmlApplicationEngine>int main(int argc, char *argv[])
{
QApplication app(argc, argv);QtQuick2ApplicationViewer viewer; viewer.setMainQmlFile(QStringLiteral("qml/untitled/main.qml")); viewer.showExpanded(); return app.exec();
}@
to:
@#include <QApplication>
#include <QQmlApplicationEngine>int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine("qml/untitled/main.qml");
return app.exec();
}@fails to compile with: 'QApplication: No such file or directory'
I don't also know what is supposed to happen with QtQuick2ApplicationViewer which i just have removed from main.cpp and it's corresponding files (header, source). It seems to contain a lot of bootstrap logic. Not to mention there's some specific configuration added to the end of the .pro file that is related to it.
I'd be very glad if anyone could outline how to start a hybrid C++/QtQuick2 with Controls project.
-
You are wrong in your assumption that you need to change anything in main.cpp. Controls are just another QtQuick 2 module, they work out of the box, at least for me. Remember to bump import statements to version 2.1:
@
import QtQuick 2.1
@Controls can be easily mixed with standard Quick components. See "this":https://github.com/sierdzio/closecombatfree/blob/master/qml/gui/menus/PreferencesMenu.qml if you are in doubt :)
As for QtQuick2ApplicationViewer: it's just a thin wrapper around QQuickView. You can safely use the base class, or the new appEngine if you prefer.
-
At least it's reasurring that not much needs to be changed :).
Ok, so I create a project via the 'QtQuick 2 Application with Built-in types' button.
I change main.qml content from:
@import QtQuick 2.0
Rectangle {
width: 360
height: 360
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}@to:
@import QtQuick 2.1
import QtQuick.Controls 1.0ApplicationWindow {
id: window
height:500
width:500Button { text: "hello" anchors.centerIn: parent onClicked: { Qt.quit(); } }
}@
Unfortunately when I start the application I get an empty white window without any child controls.
I am on windows, using this Qt 5.1 SDK build (Qt 5.1.0 for Windows 32-bit (MinGW 4.8, OpenGL, 666 MB)).
The window is empty on QtCreator 2.7.2 that comes with Qt 5.1 as well as the new QtCreator 2.8.
A project with the exact same main.qml file created via QtQuick 2 UI with Controls displays everything fine :(
-
Change ApplicationWindow into a Rectangle.
-
Should not the root object be an ApplicationWindow? It's the whole point of having QtQuick Controls.
I can't even for some reason run http://www.ics.com/blog/integrating-c-qml which is an example of C++/QML integration with QtQuick.Controls since it can't find the main.qml file.
I am going to experiment with installing different Qt 5.1 SDKs as something is definitely wrong with the MinGW build I have.
-
QQuickView starts the window for you, so there is no need for it.
-
So I finally figured it out.
There's no QtQuick 2 template with C++ integration that supports QtQuick.Controls in QtCreator out of the box as of now (version 2.8).
We will have to create an empty Qt project from scratch:
- File -> New File or Project -> Other Project -> Empty Qt Project
let's name it 'mytestproject'
-
Modify mytestproject.pro by adding this:
@
TEMPLATE = app
TARGET = mytestproject
QT += qml quick widgets
@ -
Add main.qml file to the project
@
import QtQuick 2.1
import QtQuick.Controls 1.0
ApplicationWindow {
id: rootWindow
height: 500
width: 500
visible: true // <-- this is important because the window is hidden by default
Button {
text: "Quit app"
anchors.centerIn: parent
onClicked: {
Qt.quit();
}
}
}@- Add main.cpp file to the project
@
#include <QApplication>
#include <QQmlApplicationEngine>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QQmlApplicationEngine engine("main.qml");
app.exec();
}
@- Disable Shadow build
QtCreator creates a shadow directory by default where it builds our application.
i.e if our app is located at:
/home/foo/mytestprojectthen it will create a debug and release directory at:
/home/foo/mytestproject-Debug-Desktop
/home/foo/mytestproject-Release-DesktopThis means that inside 'main.cpp' the QQmlApplicationEngine won't be able to find our 'main.qml' file that we want to load.
I don't know any other workaround, so let's just disable the shadow directory feature altogether and let's build our application inside it's folder.
To do this click on the large Projects icon on the lefthand side of QtCreator and untick 'Shadow build'.
- Build Run and Enjoy
Now the project should be building and we should be seeing a window with a buton.