qcolor

Qt5 error: ‘ColorKeyMap’ does not name a type

风格不统一 提交于 2019-12-13 03:44:22
问题 I am writing a class which has the following structure: Header File: #pragma once #include <QtCore> #include <QtGui> #include <QtWidgets> class VirtualButton : public QWidget { Q_OBJECT public: VirtualButton( QWidget *parent ); private: static QMap<unsigned int, QColor> ColorKeyMap; static QList<unsigned int> goodKeys; }; CppFile #include "VirtualButton.hpp" QMap<unsigned int, QColor> VirtualButton::ColorKeyMap = QMap<unsigned int, QColor>(); ColorKeyMap[ 23 ] = QColor( 0xff, 0x00, 0xff );

Set a button of custom color to a disabled style

拟墨画扇 提交于 2019-12-11 10:46:13
问题 I have a class that inherits QWidget . Under certain circumstances, I wish to set it disabled. The widget has some color buttons, that are set from a list of colors: void MyWidget::colorUpdate(QString color) { if(!color.isEmpty()) { QString foreground = (QColor(color).lightness() < 125 ? "white" : "black"); m_colorButton->setStyleSheet("color: " + foreground + "; background-color: " + color); } } Calling myWidget.setEnabled(enabledOption); disables the widget, grays out all text and every