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. Changing just one style aspect of Qt Quick Control
Qt 6.11 is out! See what's new in the release blog

Changing just one style aspect of Qt Quick Control

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 1.3k Views 2 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.
  • Mr. PiM Offline
    Mr. PiM Offline
    Mr. Pi
    wrote on last edited by
    #1

    Hi there,

    Suppose I create a Qt Quick Control element in QML, for example a CheckBox. The documentation suggests that any styling changes need to be done through CheckBoxStyle. So for example, to change the border color, I would use:

    CheckBox {
      id: my_checkbox
      ...
      style: CheckBoxStye {
        indicator: Rectangle {
          implicitWidth: 16
          implicitHeight: 16
          radius: 3
          border.color: "red"
        }
      }
    }
    

    However, this seems like an overly complicated way to just change the color. Creating something from scratch that looks like the original seems rather crude and it will probably break badly when targeting a different platform.
    It would make much more sense to me to re-use the already existing indicator element and change just one aspect of it, like the color. Is there a way to do that?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi, welcome to the Qt forum.

      @Mr.-Pi said:

      Is there a way to do that?

      No.

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

        Is using Qt Quick Controls 2 an option? It was first released as a tech preview in Qt 5.6 under a working title Qt Labs Controls, and the first official release in Qt 5.7. The new Qt Quick Controls 2 module takes quite different approach to styling. They are built upon customizable templates, where you can replace basically any part of any control without losing the rest of the style. Besides the minimalist default style, we offer Material and Universal styles that allow you to easily tweak colors and themes.

        1 Reply Last reply
        1
        • Mr. PiM Offline
          Mr. PiM Offline
          Mr. Pi
          wrote on last edited by
          #4

          Ok, thanks for the clear answers.

          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