Код: Выделить всё
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget* widget = new QWidget();
widget->setObjectName("widget");
QSpinBox* spinBox = new QSpinBox();
spinBox->setObjectName("spinBox");
QTextEdit* textEdit = new QTextEdit();
textEdit->setFixedSize(60, 20);
QHBoxLayout* layout = new QHBoxLayout(widget);
layout->addWidget(spinBox);
layout->addWidget(textEdit); // random widget to have something else to grab focus
widget->setStyleSheet(R"(
#spinBox
{
background-color: rgba(1, 1, 1, 255);
color: rgba(1, 1, 1, 255);
}
#spinBox::hover
{
background-color: rgba(2, 2, 2, 255);
color: rgba(2, 2, 2, 255);
}
#spinBox::disabled
{
background-color: rgba(3, 3, 3, 255);
color: rgba(3, 3, 3, 255);
}
)");
widget->show();
static const auto colorToString = [](const QColor& color) -> QString
{
return QString("rgba: %1, %2, %3, %4").arg(color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha());
};
static const auto printPallete = [](const QPalette& pal)
{
#define qq qDebug().noquote().nospace()
qq
Подробнее здесь: [url]https://stackoverflow.com/questions/79249651/how-to-retrieve-the-qpalette-colors-for-the-css-hover-state[/url]