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 Style Singleton Import
Forum Updated to NodeBB v4.3 + New Features

QML Style Singleton Import

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 946 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.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    Hi,

    I tried to follow http://wiki.qt.io/Qml_Styling for making a singleton to define my style.

    It looks like this

      pragma Singleton
      import QtQuick 2.0
      QtObject {
          property color myColor: "#000080"
      }
    

    If I import it as

         import Style 1.0
    

    and use it like this:

        Style.myColor
    

    everything is working fine. However, if I do

         import Style 1.0 as St
    

    and then try to use it as

          St.myColor
    

    is not working.

    1 Reply Last reply
    0
    • jpnurmiJ Offline
      jpnurmiJ Offline
      jpnurmi
      wrote on last edited by
      #2

      If you import the singleton type into a namespace, the singleton type name is not replaced by the namespace, but available in the namespace:

      St.Style.myColor
      
      1 Reply Last reply
      2
      • M Offline
        M Offline
        maxwell31
        wrote on last edited by
        #3

        Thank you, thats it

        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