Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to use a QQuickView class in Qt 5.12.3?
Forum Updated to NodeBB v4.3 + New Features

How to use a QQuickView class in Qt 5.12.3?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 718 Views
  • 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.
  • S Offline
    S Offline
    sinsisao
    wrote on last edited by
    #1

    Hi, I tried an example code and got some error occured.

    Please, Help me.
    Here is my code.

    #include <QGuiApplication>
    #include <QQuickView>
    #include <QUrl>
    
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
        QQuickView *pView = new QQuickView();
        pView->setSource(QUrl::fromLocalFile("main.qml"));
        pView->show();
        return app.exec();
    }
    

    with this code, I got two error.

    One: "incomplete type 'QUrl' named in nested name specifier."

        pView->setSource(QUrl::fromLocalFile("main.qml"));
    

    Two: "no member named 'show' in QQuickView."

        pView->show();
    

    For problem number one, I tried to find what namespace has the QUrl class.
    I found two define 'QT_BEGIN_NAMESPACE' and 'QT_END_NAMESPACE', I've never seen before.
    I have no idea how to use it, but also no mention about it in examples.

    I am using Qt 5.12.3 that seems the reason of problem number two and I couldn't tell how to use it in this Qt version.
    How can I use the QQuickView class?
    Where can I look for some advises or references for that?

    J.HilkJ 1 Reply Last reply
    1
    • S sinsisao

      Hi, I tried an example code and got some error occured.

      Please, Help me.
      Here is my code.

      #include <QGuiApplication>
      #include <QQuickView>
      #include <QUrl>
      
      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
          QQuickView *pView = new QQuickView();
          pView->setSource(QUrl::fromLocalFile("main.qml"));
          pView->show();
          return app.exec();
      }
      

      with this code, I got two error.

      One: "incomplete type 'QUrl' named in nested name specifier."

          pView->setSource(QUrl::fromLocalFile("main.qml"));
      

      Two: "no member named 'show' in QQuickView."

          pView->show();
      

      For problem number one, I tried to find what namespace has the QUrl class.
      I found two define 'QT_BEGIN_NAMESPACE' and 'QT_END_NAMESPACE', I've never seen before.
      I have no idea how to use it, but also no mention about it in examples.

      I am using Qt 5.12.3 that seems the reason of problem number two and I couldn't tell how to use it in this Qt version.
      How can I use the QQuickView class?
      Where can I look for some advises or references for that?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @sinsisao hi and welcome

      did you add ‚QT += quick to your pro file?

      and did you rerun qmake afterwards?


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      S 1 Reply Last reply
      1
      • J.HilkJ J.Hilk

        @sinsisao hi and welcome

        did you add ‚QT += quick to your pro file?

        and did you rerun qmake afterwards?

        S Offline
        S Offline
        sinsisao
        wrote on last edited by
        #3

        @J.Hilk Yes, I did add QT += quick in my .pro file and I rerun qmake of course.

        J.HilkJ 1 Reply Last reply
        0
        • S sinsisao

          @J.Hilk Yes, I did add QT += quick in my .pro file and I rerun qmake of course.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by J.Hilk
          #4

          @sinsisao
          I just run your code, except a warning that main.qml could not be found ( as I don't have one)

          main.qml: No such file or directory
          

          It's working fine. Everything is detected and the program executes and shows the(empty) quickview just fine.

          Qt 5.12.2 & 5.12.3 on MacOS


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          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