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. very simply style of switch ...

very simply style of switch ...

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
8 Posts 4 Posters 1.4k 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.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on last edited by aha_1980
    #1

    for first I'm on qt5.11 quickcontrol2 ... style=Default ... I would like to change the background color without having to make a qml style file with transitions and everything else. Is it possible to keep the current style with all its transitions and change only the dark-gray in blue with a single line of code?

    regards

    bkt

    ODБOïO 1 Reply Last reply
    0
    • gfxxG gfxx

      for first I'm on qt5.11 quickcontrol2 ... style=Default ... I would like to change the background color without having to make a qml style file with transitions and everything else. Is it possible to keep the current style with all its transitions and change only the dark-gray in blue with a single line of code?

      regards

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

      @gfxx hi
      edit my bad this was not for QtQuickControls 2
      see SwitchStyle
      ```
      Switch {
      style: SwitchStyle {
      groove: Rectangle {
      implicitWidth: 100
      implicitHeight: 20
      radius: 9
      color: "darkblue"
      border.width: 1
      }
      }
      }

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by SGaist
        #3

        Hi,

        For the QtQuickControls 2, the reference is here.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • gfxxG Offline
          gfxxG Offline
          gfxx
          wrote on last edited by
          #4

          i see these link .... but if use that system i loose transition effect .... so i must implement effect too ... not so easy. In these manner for change one only color in 3/4 widget i must write 300/400 row of code ... very slow system ... there are not some other system for change one only "active background color" whitout implement again all widget style? (like css manner)??

          bkt

          ODБOïO 1 Reply Last reply
          0
          • gfxxG gfxx

            i see these link .... but if use that system i loose transition effect .... so i must implement effect too ... not so easy. In these manner for change one only color in 3/4 widget i must write 300/400 row of code ... very slow system ... there are not some other system for change one only "active background color" whitout implement again all widget style? (like css manner)??

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

            @gfxx said in very simply style of switch ...:

            .. 3/4 must write 300/400 100 row of code

            you can reuse components

            1 Reply Last reply
            0
            • gfxxG Offline
              gfxxG Offline
              gfxx
              wrote on last edited by
              #6

              these for sure .... but I need only one component with that colour !!!!

              not very scalable .... In these way for first I must rewrite every component style ... than if I need a specific change i need to copy and modify component style ..... so probabily I need 30/40 or more component filestyle.qml .... not so intelligent way to do the things. Ok probabily is not so important in a bigger company project .... but in smart project .... really there are not another way to do these?

              In that case better is to use c++ widget and css code.

              in these moment I have a little idea .... where is locate the quick2 controls? I think is better copy it and modify as custom style comp.

              bkt

              1 Reply Last reply
              0
              • GrecKoG Offline
                GrecKoG Offline
                GrecKo
                Qt Champions 2018
                wrote on last edited by
                #7

                There is multiple way to do this depending on which Qt Quick Controls 2 style you are using.

                Generally you can just modify your Control's palette : https://doc.qt.io/qt-5/qml-qtquick-controls2-control.html#palette-prop
                But some style (like the Material one) don't use palette but their own attached properties instead, for example : https://doc.qt.io/qt-5/qtquickcontrols2-material.html

                gfxxG 1 Reply Last reply
                2
                • GrecKoG GrecKo

                  There is multiple way to do this depending on which Qt Quick Controls 2 style you are using.

                  Generally you can just modify your Control's palette : https://doc.qt.io/qt-5/qml-qtquick-controls2-control.html#palette-prop
                  But some style (like the Material one) don't use palette but their own attached properties instead, for example : https://doc.qt.io/qt-5/qtquickcontrols2-material.html

                  gfxxG Offline
                  gfxxG Offline
                  gfxx
                  wrote on last edited by gfxx
                  #8

                  @GrecKo ok .... but I'm on ui.qml file .... sems not consent. So I must export witch property?

                  -- Update ---

                  is these a good way to do these things:

                  QObject *myButton= object->findChild<QObject*>("myButton");
                  if (myButton)
                      myButton->setProperty("color", "red");
                  

                  There are some setPalette property for switch?

                  regards

                  bkt

                  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