PDA

View Full Version : Two independent QColorDialogs



vinnzcrafts
26th March 2014, 12:15
Hello, I'm a little confused on a program I'm writing
I created a widget that has a QColorDialog pointer, when the widget starts the QColorDialog is initiated, then it is controlled by simply using the show() and hide() functions to make it appear and desappear as the user needs it, it is modaless . The problem is when I have 2 instances of that widget, when one instance opens it's QColorDialog then the other opens it's QColorDialog, it makes the first one disappear, it is as if they were both controlling the same dialog, I have read the documentation for QColorDialog and searched for this issue with no results.
Any help appreciated, thanks in advance

wysota
26th March 2014, 12:20
This works just fine for me:


#include <QtWidgets>

int main(int argc, char **argv) {
QApplication app(argc, argv);
QColorDialog *d1 = new QColorDialog;
QColorDialog *d2 = new QColorDialog;
d1->show();
d1->move(0,0);
d2->show();
d2->move(d1->width(), 0);
return app.exec();
}

vinnzcrafts
26th March 2014, 13:42
This code only gives me one color dialog

wysota
26th March 2014, 14:03
Which version of Qt and which platform are you using? Also did you try dragging the dialog around the screen?

vinnzcrafts
26th March 2014, 14:38
Which version of Qt and which platform are you using? Also did you try dragging the dialog around the screen?

I'm using Qt 5.2 on a macOSX (10.9.2) and yes I tried dragging.

wysota
26th March 2014, 14:42
I don't have OSX so I can't try it myself but it works for me on Linux with both Qt4 and Qt5. Maybe you should try setting the option to not use the native color dialog?

vinnzcrafts
26th March 2014, 19:27
I tried to set the QColorDialog flag DontUseNativeDialog, then I opened the first dialog and clicked the close button, it closes,
then I opened again which was a good sign, but it didn't work the third time...and there is no flag or bool I have setter to control
this behavior, is all based in the isVisible() method.
Then I setted an old PC I have to test it on linux... Guess what?
It worked just fine, exactly as it was suppose to in the beginning...I also found this bug report:
https://bugreports.qt-project.org/browse/QTBUG-34532?page=com.atlassian.streams.streams-jira-plugin:activity-stream-issue-tab

So I was left with a few options on how to proceed:

1 - if the program is to run on linux and maybe windows, it is fine the way I described in the thread
2 - on the mac the color dialog will probably be modal until I find another way :(

Thanks a lot for your atention and support :)