Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPushButton setForeGroundRole
Qt 6.12 LTS is out! See what's new in the release blog

QPushButton setForeGroundRole

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 710 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #1

    I have a push button that I want the test rendered in the Link colour.

    So I did:

    ui->testCosmetic->setForegroundRole(QPalette::Link);
    

    but the text colour stubbornly remained grey. Is this a bug or am I doing this wrong?

    David

    B 1 Reply Last reply
    0
    • PerdrixP Perdrix

      I have a push button that I want the test rendered in the Link colour.

      So I did:

      ui->testCosmetic->setForegroundRole(QPalette::Link);
      

      but the text colour stubbornly remained grey. Is this a bug or am I doing this wrong?

      David

      B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      @Perdrix
      The styles don't have to call foregroundRole() to determine the text color role, so setForegroundRole may not always be effective.
      From the doc:

      Note that styles are free to choose any color from the palette. You can modify the palette or set a style sheet if you don't achieve the result you want with setForegroundRole().

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved