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. Not works style in the Switch
Forum Updated to NodeBB v4.3 + New Features

Not works style in the Switch

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 3 Posters 592 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    Hi!
    Not works style in the Switch.
    I get error: Cannot assign to non-existent property "style"

    import QtQuick 2.13
    import QtQuick.Window 2.13
    import QtQml 2.13
    import QtQuick.Controls 2.13
    import QtQuick.Controls.Styles 1.4
    
        Switch {
            id: switch1
            anchors.right: parent.right
            anchors.rightMargin: 10
            anchors.top: parent.top
            anchors.topMargin: 10
            style: SwitchStyle {
                groove: Rectangle {
                        implicitWidth: 100
                        implicitHeight: 20
                        radius: 9
                        border.color: control.activeFocus ? "darkblue" : "gray"
                        border.width: 1
                }
            }
        }
    

    .pro

    QT += quick qml core multimedia gui network positioning location sql
    
    CONFIG += c++11
    
    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by Markkyboy
      #2

      Your import statement for QtQuick.Controls is incorrect, see below;

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls.Styles 1.4
      
      import QtQuick.Controls 1.4        `<----- change to 1.4`
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Switch Style")
      
          Switch {
              id: switch1
              anchors.right: parent.right
              anchors.rightMargin: 10
              anchors.top: parent.top
              anchors.topMargin: 10
              style: SwitchStyle {
                  groove: Rectangle {
                          implicitWidth: 100
                          implicitHeight: 20
                          radius: 9
                          border.color: control.activeFocus ? "darkblue" : "gray"
                          border.width: 1
                  }
              }
          }
      }
      

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #3

        @Markkyboy said in Not works style in the Switch:

        import QtQuick.Controls 1.4

        This solution is not suitable for me, because I use Controls 2.13. Is there any other way to solve this?

        MarkkyboyM 1 Reply Last reply
        0
        • M Mikeeeeee

          @Markkyboy said in Not works style in the Switch:

          import QtQuick.Controls 1.4

          This solution is not suitable for me, because I use Controls 2.13. Is there any other way to solve this?

          MarkkyboyM Offline
          MarkkyboyM Offline
          Markkyboy
          wrote on last edited by Markkyboy
          #4

          @Mikeeeeee - change controls.styles to 1.4 as well, as per my code above. As far as I am aware neither Controls or Controls .Styles as 2.12/2.13 are not recognised.

          Don't just sit there standing around, pick up a shovel and sweep up!

          I live by the sea, not in it.

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

            @Mikeeeeee said in Not works style in the Switch:

            Controls 2.13

            I have elements from Controls 2.13

            1 Reply Last reply
            0
            • eyllanescE Offline
              eyllanescE Offline
              eyllanesc
              wrote on last edited by
              #6

              @Mikeeeeee See https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-switch

              If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.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