⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

QtDesktop & Qt components for desktop with Qt 5

  • I'm trying to get the QtDesktop components working and I'm having a heck of a time. I read "this blog post":http://blog.qt.digia.com/blog/2011/03/10/qml-components-for-desktop/ and figured this satisfied a need I have with a project I'm working on right now.

    First, I went to gitorious, and saw this:

    !http://i.imgur.com/vM0v3AD.png(QtDesktop is defunct...)!

    Clicking on the recommended link brings me to this page:

    !http://i.imgur.com/9XIayYB.png(It's all broken!)!

    Is this project still 'active'? The last check-in seems to be pretty old - April of last year? Is there a newer repository?

    Anyways, the existing QtDesktop doesn't build for Qt 5. Aside from some header inclusion differences, the 'plugin' architecture is very different between qt 4 and qt 5. I have qt 5 installed on my computer (OSX 10.8). Without knowing what I was getting into, I figured I would take a stab at porting QtDesktop to Qt 5. I have it all compiling and building and installing to imports/QtDesktop, but...

    it just doesn't work. I try to import something:

    @import QtQuick 1.1
    import QtDesktop.Button 0.1

    Rectangle {
    width: 360
    height: 360
    Text {
    id: text_box
    text: qsTr("Hello World")
    anchors.centerIn: parent
    MouseArea {
    anchors.fill: parent
    onClicked: {

    Button {
        id: button
        anchors.top: text_box.bottom
        anchors.horizontalCenter: text_box.horizontalCenter
        text: "Push me"
        onClicked: button.text = "Pressed"


    ...and at runtime Qt complains:

    @QDeclarativeDebugServer: Waiting for connection on port 3768...
    QDeclarativeDebugServer: Connection established
    file:///Users/ted/Documents/Projects/qtcreatorworkspace/build-testcomponents-OSXDesktop-Debug/testcomponents.app/Contents/Resources/qml/testcomponents/main.qml:2:1: module "QtDesktop.Button" is not installed
    import QtDesktop.Button 0.1
    Debugging has finished@

    And yet, when I look in my Qt directory, this is what I see:

    !http://i.imgur.com/He4Nd4U.png(Yup, it's all there.)!

    I'm thinking maybe I've done something wrong on the Qt 5 conversion front. Here are the files that I modified:


    Most of these are just fixing Qt 5 header issues. qdeclarativefolderlistmodel had to be changed because I guess in Qt 5 classes deriving from QAbstractListModel are supposed to override QAbstractListModel::roleNames() rather than call QAbstractListModel::setRoleNames().

    I suspect where I've gone wrong, perhaps, is qstyleplugin? I had to make some modifications to update it to the Qt 5 plugin model, but I really didn't have any idea at all what I was doing. In qstyleplugin.h I added a call to the new Q_PLUGIN_METADATA() macro:

    @class StylePlugin : public QDeclarativeExtensionPlugin
    Q_PLUGIN_METADATA(IID "QtDesktop" FILE "components.json" )
    void registerTypes(const char *uri);
    void initializeEngine(QDeclarativeEngine *engine, const char *uri);

    I have no idea what I should be putting in that IID field. Does it have to correspond to something? I've tried 'QtDesktop', 'org.qt-project.QtDesktop', and a few other things. Also, I have no idea what's supposed to go in the json file. The plug and paint example leaves the json file empty, so that's what I did. None of this seems to be documented very well, and the documentation that does exists either seems to apply to writing general Qt plugins (see the Plug and Paint plugin example), or Qml examples, but no Qt 5 Qml Qt plugin examples.

    Should I just revert to Qt 4.8.2?

  • Moderators

    This project is now integrated into Qt5.1 and renamed to Qt Quick Controls.

  • You are looking at an outdated and old repo and that code has never touched Qt 5. The new repository depends on new functionality added in Qt 5.1 so prepare to get on the bleeding edge.

    You can find the links to the current repo which compiles against Qt 5.1 here: http://qt-project.org/wiki/QtDesktopComponents

  • Thanks guys - I can't update to a prerelease version of Qt for this project (in fact, one of the platforms that I'm developing for is actually on Qt 4.6 and will require special qwidget-based forms rather than the spiffy new qml forms I'm building). I guess if this doesn't work easily with 5.0, then I'm pretty solidly on 4.8. I'll try building what's in the public repository on gitorious for 4.8.

Log in to reply