qpushbutton

How to style QPushButton's checked state to remove grey dots?

白昼怎懂夜的黑 提交于 2019-12-01 04:17:33
I am using Qt 5.3.0. When I apply some background-color on the QPushButton's checked state, the button will be filled with grey dots (over the background color I wanted) when it is checked. Here is a tiny test program (with qtcreator but it can also be done with coding): 1, create an qt application 2, drag in a QPushButton, set it to flat and checkable 3, add these lines before w.show() w.setStyleSheet("\ QPushButton { \ color:white; \ } \ QPushButton:checked{\ background-color: rgb(80, 80, 80);\ }\ QPushButton:hover{ \ background-color: grey; \ border-style: outset; \ } \ "); 4, run the app

How to style QPushButton's checked state to remove grey dots?

只谈情不闲聊 提交于 2019-12-01 01:14:13
问题 I am using Qt 5.3.0. When I apply some background-color on the QPushButton's checked state, the button will be filled with grey dots (over the background color I wanted) when it is checked. Here is a tiny test program (with qtcreator but it can also be done with coding): 1, create an qt application 2, drag in a QPushButton, set it to flat and checkable 3, add these lines before w.show() w.setStyleSheet("\ QPushButton { \ color:white; \ } \ QPushButton:checked{\ background-color: rgb(80, 80,

Flat QPushButton, background-color doesn't work

南楼画角 提交于 2019-11-30 14:10:50
I created QPushButton in Qt Designer with this stylesheet: QPushButton#pushButton { background-color: #ffffff; } QPushButton#pushButton:disabled { background-color: yellow; } QPushButton#pushButton:pressed { background-color: orange; } QPushButton#pushButton:focus:pressed { background-color: black; } QPushButton#pushButton:focus { background-color: green; } QPushButton#pushButton:hover { background-color: red; } QPushButton#pushButton:checked { background-color: pink; } It Works, but when i check "flat" in the properties, then it doesn't work anymore, I would like to ask you why? And how can i

QMenu: How to customize the menu items of QMenu

假装没事ソ 提交于 2019-11-30 09:29:14
问题 I want to build a dropdown list control with QPushButton and QMenu like below: QPushButton* menuBt = new QPushButton("Please select"); menuBt->setFlat(true); QMenu* menu = new QMenu(); menuBt->setMenu(menu); QWidgetAction* wa1 = new QWidgetAction(menu); QLabel* l1 = new QLabel("Option1"); wa1->setDefaultWidget(l1); menu->addAction(wa1); QWidgetAction* wa2 = new QWidgetAction(menu); QLabel* l2 = new QLabel("Option2"); wa2->setDefaultWidget(l2); menu->addAction(wa2); menu->setStyleSheet("QMenu:

Flat QPushButton, background-color doesn't work

风格不统一 提交于 2019-11-29 19:48:19
问题 I created QPushButton in Qt Designer with this stylesheet: QPushButton#pushButton { background-color: #ffffff; } QPushButton#pushButton:disabled { background-color: yellow; } QPushButton#pushButton:pressed { background-color: orange; } QPushButton#pushButton:focus:pressed { background-color: black; } QPushButton#pushButton:focus { background-color: green; } QPushButton#pushButton:hover { background-color: red; } QPushButton#pushButton:checked { background-color: pink; } It Works, but when i

QMenu: How to customize the menu items of QMenu

拟墨画扇 提交于 2019-11-29 15:38:19
I want to build a dropdown list control with QPushButton and QMenu like below: QPushButton* menuBt = new QPushButton("Please select"); menuBt->setFlat(true); QMenu* menu = new QMenu(); menuBt->setMenu(menu); QWidgetAction* wa1 = new QWidgetAction(menu); QLabel* l1 = new QLabel("Option1"); wa1->setDefaultWidget(l1); menu->addAction(wa1); QWidgetAction* wa2 = new QWidgetAction(menu); QLabel* l2 = new QLabel("Option2"); wa2->setDefaultWidget(l2); menu->addAction(wa2); menu->setStyleSheet("QMenu::item {font-family: \"Arial\"; font-size: 13pt; color: #808080; border: 1px solid gray; background

How to do - QToolButton inside the QlineEdit : Qt5

梦想的初衷 提交于 2019-11-29 12:38:48
I want to add QToolButton inside the QLineEdit . I want to clear the text of QLineEdit control on that button click. For example how in google image: I have looked : This StackOverflow article But still not solved my issue. Thanks in Advance. This behaviour is available as a direct property to QLineEdit since Qt 5.2 : https://qt-project.org/doc/qt-5/qlineedit.html#clearButtonEnabled-prop QLineEdit *edit = new QLineEdit(this); edit->setClearButtonEnabled(true); You can add a custom QAction with your self-defined icons to the QLineEdit: https://qt-project.org/doc/qt-5/qlineedit.html#addAction

How to override just one property:value pair in Qt StyleSheet

隐身守侯 提交于 2019-11-29 05:47:27
I am writing newbie Qt5 code on OSX Mavericks and would like to override just one property:value pair of the StyleSheet for a given widget. If I run the following self-contained demonstration code: #include <QApplication> #include <QMainWindow> #include <QtGui> #include <QPushButton> int main( int argc, char *argv[] ) { QApplication app( argc, argv ); QMainWindow* mw = new QMainWindow(); QPushButton* AButton = new QPushButton( "A Button", mw ); mw->show(); return app.exec(); } I get a nice pushbutton with Macintosh style defaults -- rounded corners, standard OSX-blue color when pressed, etc.:

Qt5 - setting background color to QPushButton and QCheckBox

隐身守侯 提交于 2019-11-29 03:43:40
I'm trying to change the background color of a QAbstractButton (either a QPushButton or QCheckBox) in Qt5 and having zero luck. This does nothing: pButton->setAutoFillBackground(true); QPalette palette = pButton->palette(); palette.setColor(QPalette::Window, QColor(Qt::blue)); pButton->setPalette(palette); pButton->show(); and if I try changing the style sheet: pButton->setStyleSheet("background-color: rgb(255,255,0);"); then Qt throws up its hands and draws an afwul-looking blocky button. There is a page titled " How to change the background color of QWidget " but it just talks about those

QPushButton alignment on top another widget

梦想的初衷 提交于 2019-11-28 12:13:23
问题 I have a QListWidget and a QPushButton that clears the QListWidget . Right now my button is next to the QListWidget leaving awkward empty space. I would like to place the button over the QListWidget so that is would cover the right bottom corner. I tried just placing the button like this QPushButton* button = new QPushButton(ui->listwidget); button->show(); And it does create a "floating" button over my widget, but I can't seem to find a way to place it correctly. Maybe I could by trials-and