How to link signal of QColorDiaglog to a slot.
Solved
General and Desktop
-
This is my code where i am opening a QColor diaglog.
I want to reflect the change of color in realtime so want to link the colorChanged signal to a function.
How can i link currentColorChanged(const QColor &color) of QDiaglog to slot ParamChangeCurrentKeyColor.
void Sum_ChromaKey::ParamChangeKeyColor() { QColor color; int r, g, b; color = QColorDialog::getColor(); // link currentColorChanged signal to ParamChangeCurrentKeyColor color.getRgb(&r, &g, &b); _KeyColor.r = r; _KeyColor.g = g; _KeyColor.b = b; // currentColorChanged(const QColor &color) } void Sum_ChromaKey::ParamChangeCurrentKeyColor(const QColor &color) { _KeyColor.r = color.red; _KeyColor.g = color.green; _KeyColor.b = color.blue; }
-
Hi
you need to create your own instance in connect to that
QColorDialog col; connect(&col, &QColorDialog::currentColorChanged,this, &Sum_ChromaKey::ParamChangeCurrentKeyColor); col.exec();
-
@summit
Hi
Call open instead and then you need to use a pointerQColorDialog * col = new QColorDialog(); col->setAttribute(Qt::WA_DeleteOnClose); // this deletes it when closed connect(col, &QColorDialog::currentColorChanged,this, &MainWindow::ParamChangeCurrentKeyColor); col->open();