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. Custom Quick Controls Style not found
Qt 6.11 is out! See what's new in the release blog

Custom Quick Controls Style not found

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 640 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
    Matt Chaput
    wrote on last edited by
    #1

    Only thing I can find for how to make a custom style is this:

    https://doc.qt.io/qt-6/qtquickcontrols-customize.html#creating-a-custom-style

    Trying to follow that, I created the following structure:

    Test/
      test.qml
      MyStyle/
        qmldir
        Button.qml
    

    When I cd into Test and run qml -style MyStyle test.qml, I get module "MyStyle" is not installed but it's in the current directory which is supposed to part of the import path.

    Anyone know what's wrong here?

    qmldir:

    module MyStyle
    Button 2.15 Button.qml
    

    Button.qml

    import QtQuick
    import QtQuick.Templates as T
    
    T.Button {
        background: Rectangle {
            color: "#ff9900"
        }
    
        contentItem: Text {
            text: parent.text
            color: "black"
        }
    }
    

    test.qml:

    import QtQuick
    import MyStyle
    
    Pane {
        width: 600
        height: 600
    
        Column {
            anchors.fill: parent
    
            padding: 50
            spacing: 25
    
            Row {
                spacing: 25
                Button { text: "Button" }
                Button { text: "Button"; enabled: false }
            }
    
            Row {
                spacing: 25
                CheckBox { text: "Checkbox" }
                CheckBox { text: "Checkbox"; checked: true }
            }
    
            Row {
                spacing: 25
                Switch {}
                Switch { checked: true }
            }
    
            Label { text: "Label" }
        }
    }
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      Matt Chaput
      wrote on last edited by
      #2

      Welp, even though I think the docs says that the directory containing the current file is automatically part of the import path, it doesn't seem to be the case. If I do this, it works:

      QML_IMPORT_PATH=. qml -style MyStyle test.qml
      
      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