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 combine Qt/c++ file with a qml file in one project?
Forum Updated to NodeBB v4.3 + New Features

How to combine Qt/c++ file with a qml file in one project?

Scheduled Pinned Locked Moved QML and Qt Quick
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.
  • Y Offline
    Y Offline
    ysing
    wrote on last edited by
    #1

    Hi everybody ,

    I'm developing a c++ application using Qt and I'm using Qt quick for the design .The problem that I am facing is that I didn't know how to combine a qml file with a c++ file in the same project I mean how to make the link between them ?

    I also want to know haw to apply the signal & slot concept with qml?

    Can anybody help me please ?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      This is covered thoroughly in "the documentation":http://qt-project.org/doc/qt-5/qtqml-cppintegration-topic.html.

      Basically, there are 3 options:

      • expose C++ class as a QML Singleton
      • add C++ class as a root context property
      • implement a QQuickItem or QQuickPaintedItem in C++ and use it in QML

      (Z(:^

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        ysing
        wrote on last edited by
        #3

        Ok I will try and I hope I could fix the problem .

        Do you yu know why an error occurs when I change the project file name ?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          No. Please at least provide the error message here and I will try to help you.

          (Z(:^

          1 Reply Last reply
          0
          • Y Offline
            Y Offline
            ysing
            wrote on last edited by
            #5

            Ok I actually changed the project file name then when i reopened the project and I pressed run the following errors are displayed :

            D9024:unrecoognised source fil type '....%the previous project file name%', object file assumed
            D9027:source file '....%the previous project file name%' ignored

            C1803:cannot open source file %the previous project file name%' no such file or directory

            I Tried the following solutions:

            1. clean->run qmake-> run
            2. the project file name cantained a space I've changed it to another name of one word(without spaces)

            but the error persists

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              Probably a session problem. Please do this:

              Exit Qt Creator

              Browse to where your project is located

              Delete <your project name>.pro.user

              Start Qt Creator again

              Open your project anew

              (Z(:^

              1 Reply Last reply
              0
              • Y Offline
                Y Offline
                ysing
                wrote on last edited by
                #7

                Thanks sierdzio that worked very well !!

                but can you explain for me how did you know that it is a session problem ?

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  It was an educated guess. Qt Creator uses .pro.user files to store local configuration of the project. If you change the name of the pro file wihtout setting up a new session, that file will hold corrupted session info.

                  (Z(:^

                  1 Reply Last reply
                  0
                  • Y Offline
                    Y Offline
                    ysing
                    wrote on last edited by
                    #9

                    Ok , Thank you for the clarification.

                    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