qcheckbox

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

Qt - Centering a checkbox in a QTable

女生的网名这么多〃 提交于 2019-11-28 08:05:10
问题 In QtCreater I added a table to my project. in my code I am generating some data to output into the table. I want to add a QCheckbox into each row to allow the row to be selected. All the content of the table is aligned left, how do I make only these checkboxes in the first column of every row align to the center? I'm adding the QCheckbox using: ui->data_table->setCellWidget(rowCount,0, new QCheckBox); 回答1: I usually use a layout and a container widget for this. It is an ugly solution, but it

Qt5 - setting background color to QPushButton and QCheckBox

一世执手 提交于 2019-11-27 17:34:31
问题 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.

how to change QCheckBox text label color in Qt?

南楼画角 提交于 2019-11-27 06:58:37
问题 I'm unable to change the color of Qcheckbox in QT , can somebody help me with code to change color of check box text label. I have tried Qpalette .. And im using QT4.7.4 version.. 回答1: You could use stylesheets. e.g: checkBox->setStyleSheet("QCheckBox { color: red }"); For more details check the style sheets in Qt Reference and the stylesheets documentation 回答2: This works for me: QPalette p = myCheckBox->palette(); p.setColor(QPalette::Active, QPalette::WindowText, green); myCheckBox-