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; "Blurry" stylesheet for checked buttons

QPushButton; "Blurry" stylesheet for checked buttons

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

    I have two buttons in a button group, and I want the checked button to have a blue background with white text, and the unchecked button white background with blue text.

    This my GUI setup:

        mvLBtn = new QPushButton("btn1");
        mvLBtn->setCheckable(true);
        mvLBtn->setChecked(true);
        mvMlBtn = new QPushButton("btn2");
        mvMlBtn->setCheckable(true);
    
        QWidget *mvGrp = new QWidget;
        QButtonGroup *mvBGp = new QButtonGroup;
        mvBGp->addButton(mvLBtn);
        mvBGp->addButton(mvMlBtn);
        QHBoxLayout *mvLayout = new QHBoxLayout;
        mvLayout->setMargin(0);
        mvLayout->setSpacing(0);
        mvLayout->addWidget(mvLBtn);
        mvLayout->addWidget(mvMlBtn);
        mvGrp->setLayout(mvLayout);
    

    This mvGrp widget is added the form later in a couple nested layouts.

    This is my stylesheet:

    this->setStyleSheet("QPushButton{margin: 0px; padding: 10px;}"
                            "QPushButton:checked{background-color: blue; color: white;}"
                            "QPushButton:!checked{background-color: white; color: blue;}");
    

    For some reason, the checked button (btn1) is blurry on the form.

    0_1531251405806_007d5f79-8959-4bb6-9389-4f71843ab9e8-image.png

    However, I've noticed that if I switch my stylesheet for checked vs !checked, the unchecked button does NOT have the same blurry affect.

    Switched stylesheet:

    this->setStyleSheet("QPushButton{margin: 0px; padding: 10px;}"
                           "QPushButton:checked{background-color: white; color: blue;}"
                           "QPushButton:!checked{background-color: blue; color: white;}");
    

    Form with btn1 checked:

    0_1531251472395_aa33ca8f-d668-4d36-a310-6b4bf81d2275-image.png

    How can I get my form to have a solid blue background on checked buttons?

    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