Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Trouble getting QML file to work
Forum Updated to NodeBB v4.3 + New Features

Trouble getting QML file to work

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nicky j
    wrote on last edited by JKSH
    #1

    Hello,

    I have built a C++ application that has a QDeclarativeView designed to show a QML file. Whenever I try and run the application however, I get this compiler message:

    module "QtQuick" version 2.0 is not installed 
         import QtQuick 2.0 
         ^
    

    What am I doing wrong?

    here is my hud.qml:

    import QtQuick 2.0
    
    Rectangle {
        width: 100
        height: 62
        opacity: 0.5
        color: "red"
    }
    

    here is my hud.cpp:

    #include "hud.h"
    
    hud::hud(QWidget *parent) :
        QMainWindow(parent)
    {
        this->setAttribute( Qt::WA_TranslucentBackground );
        //this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
        this->setStyleSheet(
                        "background-color:rgba(255,255,255,0.5);"
                        );
    
    
        QDeclarativeView *hudView = new QDeclarativeView;
        hudView->setSource(QUrl::fromLocalFile("/Users/nick/Desktop/Development/QT dev/hud_v4/hud.qml"));
        hudView->setStyleSheet(
                        "background-color:rgba(255,255,255,0.5);"
                        );
    
        QVBoxLayout *layout = new QVBoxLayout;
        layout->addWidget(hudView);
        this->setLayout(layout);
    
        setCentralWidget(hudView);
    }
    
    hud::~hud()
    {
    
    }
    

    and the hud.pro:

    QT       += core gui
    QT += quick
    QT += declarative
    
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = hud_v4
    TEMPLATE = app
    
    
    SOURCES += main.cpp\
            hud.cpp
    
    HEADERS  += hud.h
    
    FORMS    +=
    
    OTHER_FILES += \
        hud.qml
    

    Thank you!

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      QDeclarativeView is for Qt Quick 1. Use QQuickView instead.

      You also seem to have made your HUD inherit a QMainWIndow -- is this intentional? I thought you wanted your HUD to display on top your your main window.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nicky j
        wrote on last edited by
        #3

        Are there any plans to update QDEclarativeView for Qt Quick?

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by JKSH
          #4

          @nicky-j said:

          Are there any plans to update QDEclarativeView for Qt Quick?

          QQuickView IS the updated version of QDeclarativeView: http://doc.qt.io/qt-5/qtquick-porting-qt5.html#c-code

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nicky j
            wrote on last edited by
            #5

            Can QQuickView be embedded in a QMainWindow?

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by JKSH
              #6

              @nicky-j said:

              Can QQuickView be embedded in a QMainWindow?

              Yes. Use http://qt-project.org/forums/viewthread/38501/

              Qt 5.3 will make it even easier with the introduction of a QQuickWidget class.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              0
              • N Offline
                N Offline
                nicky j
                wrote on last edited by
                #7

                oh then I may just work on the QML part right now and wait for QQuickWidget to come out to integrate it to the rest of my program. Is 5.3 coming out soon?

                1 Reply Last reply
                0
                • JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by JKSH
                  #8

                  @nicky-j said:

                  oh then I may just work on the QML part right now and wait for QQuickWidget to come out to integrate it to the rest of my program. Is 5.3 coming out soon?

                  This is the release plan: http://qt-project.org/wiki/Qt-5.3-release

                  The Alpha release was scheduled for today, but the previous step was delayed by a few days.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    nicky j
                    wrote on last edited by
                    #9

                    ok awesome! gives me a bit of time to hone my QML skills :P

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved