Hello,
I'm trying to write me a color picker widget. The idea is, that it folds up from a smaller 'Select Color'-Button, and disappears if the user clickes anything else than the picker widget. So the widget is non-modal. (Think it similar to a drop down listbox.) Additional I would like to keep the applications UI responsive while the user is picking the color, to update the preview in the main view and - this is where the problem comes in - and to do this via an exec()-function containing a message loop (like the QFileDialog).
bool DropDownColorPickerWidget::exec()
{
m_result = true;
show();
eventLoop.processEvents();
activateWindow();
while( isVisible() )
eventLoop.processEvents();
return m_result;
}
bool DropDownColorPickerWidget::exec()
{
m_result = true;
show();
QEventLoop eventLoop( this );
eventLoop.processEvents();
activateWindow();
while( isVisible() )
eventLoop.processEvents();
return m_result;
}
To copy to clipboard, switch view to plain text mode
In general this seems to work, but when parent-widget of the picker widget is closed while the application is inside the pickers message loop this causes a crash.
So I´m looking for a possiblity for either preventing the parent widgets (and the application) from closing while the picker is poped up or for a way to exit the message loop before the deletion of the parent objects takes place.
Thanks in advance for any hints or advice.
Bookmarks