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 Singleton with AutoComplete(IntelliSense)
Qt 6.11 is out! See what's new in the release blog

Qml Singleton with AutoComplete(IntelliSense)

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 1.1k 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.
  • E Offline
    E Offline
    Eligijus
    wrote on last edited by
    #1

    Hello,

    I want to use qml Singleton in my project and I can't get AutoComplete to work.

    //Styles.qml
    pragma Singleton
    import QtQuick 2.11
    
    QtObject {
        property QtObject cars: QtObject {
            property string luxury: "bmw"
            property string exotic: "ferrari"
        }
    }
    
    

    I register singleton:

        qmlRegisterSingletonType(QUrl("qrc:///singletons/Styles.qml"), "My.Examples", 1, 0, "Styles");
    
    import QtQuick 2.11
    import QtQuick.Window 2.11
    import My.Examples 1.0
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        Text {
            text: Styles.cars.exotic
        }
    }
    

    I get the expected output "ferrari" but when I type Styles. I should get a dropdown where I could select cars but it doesn't work.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      It is issue with editor. It may have difficulty in recognising the type. Hence the issue.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      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