Hi, so I just now realised, that I've made a mistake in my code example. Everytime you click cancel the color that it returns is black.
EDIT: It's a problem because I'm setting a widgets color, and when I click cancel, it sets without me wanting it to.
Here it's fixed:
QString color;
QColorDialog pick;
pick.setStyleSheet("stylesheet");
pick.setCurrentColor("10, 255, 10"); //optional
if (pick.exec() == QColorDialog::Accepted) {
QColor const color = pick.selectedColor().name();
color = color.name();
qDebug() << color;
}
Another EDIT: Here's an example of 2 different stylesheets:
Light mode:
QColorDialog {background-color: rgb(244, 244, 244);}
QPushButton {background-color: rgb(244, 244, 244); color: black;}
QLabel {background-color: rgb(244, 244, 244); color: black;}
QLineEdit {background-color: white; color: black;}
QSpinBox {background-color: white; color: black;}
Dark mode:
QColorDialog {background-color: rgb(6, 6, 14);}
QPushButton {color: rgb(211, 213, 201); background-color: rgb(36, 36, 44);}
QLabel {color: rgb(211, 213, 201); background-color: rgb(6, 6, 14);}
QLineEdit {color: rgb(211, 213, 201); background-color: rgb(36, 36, 44);}
QSpinBox {color: rgb(211, 213, 201); background-color: rgb(36, 36, 44);}