Fri, 07 Feb 2020 02:01:21 +0200
wrote the id color in terms of the id value in the shader now that I can get the id to the shader properly
#include <QColorDialog> #include "colorbutton.h" ColorButton::ColorButton(const QColor& color, QWidget* parent) : ColorButton{parent} { this->setSelectedColor(color); } ColorButton::ColorButton(QWidget* parent) : QPushButton{parent} { connect(this, &QPushButton::clicked, [&]() { const QColor color = QColorDialog::getColor(this->storedSelectedColor, this->parentWidget()); if (color.isValid()) { this->setSelectedColor(color); } }); } QColor ColorButton::selectedColor() const { return this->storedSelectedColor; } void ColorButton::setSelectedColor(const QColor& newSelectedColor) { this->storedSelectedColor = newSelectedColor; this->setStyleSheet(QString{"background-color: %1"}.arg(newSelectedColor.name())); this->setText(newSelectedColor.name()); }