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. QML Styling in Hybrid C++/QML application
Forum Updated to NodeBB v4.3 + New Features

QML Styling in Hybrid C++/QML application

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 458 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.
  • S Offline
    S Offline
    SocketSackett
    wrote on last edited by
    #1

    Hi, Currently, we are on Qt 5.15.5. We have a hybrid application with a good bit of C++ code (80%) & some panes are QML (20%) that are read in at run-time. I'm trying to get some basic styling working. I have kept it simple to start with to aim to get it working with one case. Everytime I "import Style 1.0 Style.qml", it doesn't work & the QML is not loaded to display. I have a QML directory, within which I have Style.qml (just QtObject { property color textColor: "black" }), app_qml.qrc for resource file, quickcontrols2.conf (referencing Material), & a qmldir called module Style with Style 1.0 Style.qml. I have the QML imported, I am building with the QRC definition in the .pro file, but if I do import Style 1.0 Style.qml, then the QML file in which it is imported fails to load with a reference error. I have tried & played with different things, but the problem persists. I just want to do simple styling such as text color & so forth that can be referenced in the QML file, but so far it is not working. Perhaps someone has a suggestion.

    ODБOïO 1 Reply Last reply
    0
    • S SocketSackett

      Hi, Currently, we are on Qt 5.15.5. We have a hybrid application with a good bit of C++ code (80%) & some panes are QML (20%) that are read in at run-time. I'm trying to get some basic styling working. I have kept it simple to start with to aim to get it working with one case. Everytime I "import Style 1.0 Style.qml", it doesn't work & the QML is not loaded to display. I have a QML directory, within which I have Style.qml (just QtObject { property color textColor: "black" }), app_qml.qrc for resource file, quickcontrols2.conf (referencing Material), & a qmldir called module Style with Style 1.0 Style.qml. I have the QML imported, I am building with the QRC definition in the .pro file, but if I do import Style 1.0 Style.qml, then the QML file in which it is imported fails to load with a reference error. I have tried & played with different things, but the problem persists. I just want to do simple styling such as text color & so forth that can be referenced in the QML file, but so far it is not working. Perhaps someone has a suggestion.

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      hi
      i would suggest simplifying the question if possible
      also see https://wiki.qt.io/Qml_Styling

      S 1 Reply Last reply
      0
      • ODБOïO ODБOï

        hi
        i would suggest simplifying the question if possible
        also see https://wiki.qt.io/Qml_Styling

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

        @ODБOï I have already read that & followed, but still not working. There's something missing in the instructions -- it is incomplete.

        ODБOïO 1 Reply Last reply
        0
        • S SocketSackett

          @ODБOï I have already read that & followed, but still not working. There's something missing in the instructions -- it is incomplete.

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          @SocketSackett said in QML Styling in Hybrid C++/QML application:

          There's something missing in the instructions

          What exactly ?

          Can you simplify you question, show us what exactly are you doing and what is the error ?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mammamia
            wrote on last edited by Mammamia
            #5

            @SocketSackett
            This might be due to QmlEngine failed to see where the qmldir is.

            here is my blog post and example of how to create a shared QML component library.
            https://arunpkqt.wordpress.com/2020/07/25/shared-qml-component-library/

            We need to also pass the path to qmldir to the QQmlEngine to search for the installed modules. This path may be a local filesystem directory, a Qt Resource path (:/imports), a Qt Resource url (qrc:/imports) or a URL. As we have already included the qrc file in aforementioned step we could use
            
            1
            engine.addImportPath(":/imports");
            4. In the QML file import the module as
            
            1
            import com.apk.components 1.0 as Apk
            

            hope that helps!

            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