Home > Software design >  How i can disable highlight on a QPushbutton?
How i can disable highlight on a QPushbutton?

Time:10-08

Qt 5.11 Linux

I am brand new to Qt development and I am hoping you guys might be able to help me with a GUI / Stylesheet issue.

How i can disable button highlight on a my icon flat QPushButton: It's looks like:

Image

Code:

m_settingsPushButtton=new QPushButton();
m_settingsPushButtton->setCheckable(true);
m_settingsPushButtton->setChecked(false);
m_settingsPushButtton->setFlat(true);
m_settingsPushButtton->setIcon(QIcon(":/images/settings2"));

At first i think that it could be default settings:

m_settingsPushButtton->setDefault(false);
m_settingsPushButtton->setAutoDefault(false);

But it don't. Problem still occurs I would think that is because this button that has the focus I set:

m_settingsPushButtton->setFocusPolicy(Qt::NoFocus);

But it's don't help again. Okay may be i need to set button Transapent..

QPalette Theme = m_themePushButtton->palette();
Theme.setColor(QPalette::Button, QColor(Qt::transparent));
m_themePushButtton->setPalette(pal);

No result. How to disable this highlight. Thanks.

CodePudding user response:

You should to set a button border as 0 using StyleSheets:

m_themePushButtton->setStyleSheet("border: 0px;");

It might be help

  • Related