Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPushButton border color
Forum Updated to NodeBB v4.3 + New Features

QPushButton border color

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 994 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.
  • G Offline
    G Offline
    Grand_Titan
    wrote on 26 Oct 2023, 09:37 last edited by
    #1

    I want to color the border of a button depending on some conditions. Im currently doing it like this:
    ui->buttonCompile->setStyleSheet(uncompiledButton);
    ui->buttonCompile->setStyleSheet(compiledButton);
    QString uncompiledButton = "border: 2px solid red;";
    QString compiledButton = "border: 2px solid green;";
    But these things have side effects like the font changing and on Win11 the button will be square. Also the color of the button slightly changes. I want to keep the default look of the button and just change the color of the border. The button is created and defined in mainwindow.ui. How can I achieve that?

    J 1 Reply Last reply 26 Oct 2023, 12:24
    0
    • G Grand_Titan
      26 Oct 2023, 09:37

      I want to color the border of a button depending on some conditions. Im currently doing it like this:
      ui->buttonCompile->setStyleSheet(uncompiledButton);
      ui->buttonCompile->setStyleSheet(compiledButton);
      QString uncompiledButton = "border: 2px solid red;";
      QString compiledButton = "border: 2px solid green;";
      But these things have side effects like the font changing and on Win11 the button will be square. Also the color of the button slightly changes. I want to keep the default look of the button and just change the color of the border. The button is created and defined in mainwindow.ui. How can I achieve that?

      J Offline
      J Offline
      JonB
      wrote on 26 Oct 2023, 12:24 last edited by JonB
      #2

      @Grand_Titan
      I think you have a problem. Elements have an in-built style. As soon as you place any CSS on them they lose this, that's why you see it look so different. You may find you can only change that in code (QStyle, QPalette), not via CSS.

      1 Reply Last reply
      1
      • G Grand_Titan has marked this topic as solved on 26 Oct 2023, 18:29

      1/2

      26 Oct 2023, 09:37

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved