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. Setting the default color of ALL text elements
Forum Updated to NodeBB v4.3 + New Features

Setting the default color of ALL text elements

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 2.2k 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.
  • W Offline
    W Offline
    wost
    wrote on last edited by
    #1

    Doing some work with QML elements, and I would like every Text-element to have a default color if none is given to them. Instead of giving all Text-elements the default color of black, I would like to set a custom color. Is this possible?

    I've thought about just making a custom component (with a few default properties) and replace every instance of the Text-element with this. However, there are A LOT of Text-elements and I would possibly break many components if I try to go this route.
    Is there anything I can do in C++, maybe?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      If you are using QtQuick.Controls (1 or 2) you can use styles to apply custom look to all components.

      If you are talking about basic Text component, then there is a way: create Text.qml file (exactly the same name as the basic type), set the color there, and then make sure it's directory is imported in your other qml files. The QML engine should pick up your new implementation instead of basic type.

      (Z(:^

      1 Reply Last reply
      2
      • ibiaI Offline
        ibiaI Offline
        ibia
        wrote on last edited by
        #3

        You can also set this in C++. You can modify the default font of the QGuiApplication.

        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