Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator/Designer and QML issue
QtWS25 Last Chance

Qt Creator/Designer and QML issue

Scheduled Pinned Locked Moved Qt Creator and other tools
10 Posts 4 Posters 5.3k 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.
  • E Offline
    E Offline
    EricRFMA
    wrote on 16 Feb 2014, 21:31 last edited by
    #1

    Hello...

    I've just started with QML/QtQuick and have come up with an issue when editing with the designer in Qt Creator.

    When I try to work on my QML in designer, I get this when I bring it up:

    !http://feigenson.net/ForumUploads/ScreenShot2014-02-16at4.20.06PM.jpg(Qt Designer error)!

    The error is here on line 3:

    @import QtQuick 2.1
    import QtQuick.Controls 1.0
    import com.erflink.WeightPlates 1.0 as WeightPlate@

    The project builds and runs fine, since I register the C++ class with QML:
    @qmlRegisterSingletonType<MainWindow>("com.erflink.WeightPlates", 1, 0, "WeightPlateAPI", QML_MainWindow);@
    but the designer doesn't see it, presumably because the <code>qmlRegisterSingltetonType</code> happens only at run-time.

    So right now, I have to comment out that <code>import</code> line in order to edit my QML in designer.

    Is that the only way to do it?

    Thanks!

    -Eric

    1 Reply Last reply
    0
    • T Offline
      T Offline
      ThomasHartmann
      wrote on 17 Feb 2014, 17:11 last edited by
      #2

      You could either create a QML plugin for "com.erflink.WeightPlates"
      and use QML_IMPORT_PATH/importPaths to point to it, or you could just create an empty fake plugin for "com.erflink.WeightPlates".

      If you use the fake plugin approach anything defined in "com.erflink.WeightPlates" will not work in the designer, but you will not get any error messages.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        EricRFMA
        wrote on 18 Feb 2014, 04:45 last edited by
        #3

        Thanks for your reply!

        Excuse my lack of knowledge in this area, but, to create a QML plugin, is that referred to as a "Qt Quick 2 Extension Plugin" in the "New project templates" dialog? Or is it a "Qt Creator Plugin?"

        I tried with the Qt Quick Extension template, put the plugin in the Qt Creator's plugin directory, and it didn't seem to get noticed. Of course, I'm not quite sure what I'm doing with the setup for the plugin in the first place.

        Would you please help me fill in some of the blanks? I'd appreciate it.

        Thanks!

        -Eric

        1 Reply Last reply
        0
        • T Offline
          T Offline
          ThomasHartmann
          wrote on 19 Feb 2014, 10:40 last edited by
          #4

          Hi,

          Yes I was talking about a “Qt Quick 2 Extension Plugin” .
          For the Qt Quick plugin to be found, you need to add the path to QML_IMPORT_PATH in the .pro file.
          You might also need a .qmltypes file which contains the meta informatino for the code model.

          If the types defined in C++ are not directly relevant for designing, you can also just create a dummy plugin, but you still need to add the path to QML_IMPORT_PATH.

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hmuelner
            wrote on 25 Apr 2014, 09:06 last edited by
            #5

            I am having the same problem using Qt Creator 3.1.0 and Qt 5.3.0 RC snapshot. I do not have any plugin dlls, my qmlRegisterSingletonType is in the main.cpp of my project. How to I tell the Qt Creator designer that this type exists?

            Helmut Mülner

            1 Reply Last reply
            0
            • T Offline
              T Offline
              ThomasHartmann
              wrote on 25 Apr 2014, 11:18 last edited by
              #6

              My guess is that qmlRegisterSingletonType is not properly supported by the code model of Qt Creator.

              Any use of your singleton should be marked as an error by the code editor in this case. If this is the case can you create a mini example and file a bug report?

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hmuelner
                wrote on 25 Apr 2014, 11:26 last edited by
                #7

                Only the import statement is marked as an error ("QML module not found"), the calls to the Singleton method(s) are not marked as an error. I suspect that I only have to put a qmldir file somewhere, but I did not find any documentation about the contents and the location of the file for this use case.

                Helmut Mülner

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  ThomasHartmann
                  wrote on 25 Apr 2014, 11:39 last edited by
                  #8

                  In the .pro file you can use QML_IMPORT_PATH to extend the search path for qml plugins.
                  In this directory you can then put "fake" plugins in e.g. com/erflink/WeightPlates.

                  the qmldir file would look like this:
                  module com.erflink.WeightPlates

                  For details you can look here: http://qt-project.org/doc/qt-5/qtqml-modules-qmldir.html

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hmuelner
                    wrote on 25 Apr 2014, 12:13 last edited by
                    #9

                    Thank you, the "module" line did it. I think that use case should really be documented.

                    Helmut Mülner

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      baobaojiu
                      wrote on 6 Jun 2014, 10:44 last edited by
                      #10

                      same issue, I need create a fake extension project.
                      But the problem is I have more than ten types to be registered. I need create them all.
                      I think it really can be a bug in QT Creator.

                      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