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 1.0k 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 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?

    JonBJ 1 Reply Last reply
    0
    • G Grand_Titan

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on 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

      • Login

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