Solved QColorDialog on clicking cancel is by default taking black color.
color dialog when clicked cancel is taking black instead of taking the previous color.Below is the code.please suggest
QColorDialog *qcolor = new QColorDialog (this);
QColor color = qcolor->getColor();
backgroundcolor = new QColor (color);
@Sriu1 "The dialog is a child of parent. It returns an invalid (see QColor::isValid()) color if the user cancels the dialog." - http://doc.qt.io/qt-5/qcolordialog.html#getColor
Also getColor() is a static method there is no need to create an instance (and it can't have "previos color" for that reason).
I tried if(color.isValid()) ,but the color is setting to white on cancel clicked.I want previously selected color to be retained instead on taking white or black.
@Sriu1 And what does color.isValid() return in your case? There can't be "previous color" as getColor() is a static method.