Setting QColorDialog position: QColorDialog::move(int x, int y) does not seem to work



  • Hello, I create a QColorDialog that is not modal in a custom QDialog (it's parent) and then pass it to a custom QObject (a controller).
    The controller is in charge of a number of things such as setting the currentColor, but it also has the function of showing the colorDialog when the user needs to pick a color (for my implementation, I need a single QColorDialog to handle all color choosing).

    The problem is that after the user "closes" the dialog, by clicking "OK" or "Cancel", a subsequent call of colorDialog->show() will result in the dialog being shown directly in front of the QDialog. Since the user needs to interact both with the QDialog and with the colorDialog, it has to keep dragging it to be able to see what's underneath it.

    Calling colorDialog->move(int x, int y) either in it's parent (the QDialog) or the controller does not seem to affect it's position. Curiously, colorDialog->pos() does show the updated position according to move(). But the ColorDialog is still always displayed in front of the regular QDialog.

    Is there any way for me to move the position of the QColorDialog from code?

    Regards,
    Eduard Nicodei



  • Hi Eduard.
    you have to map the position to the parent of your QDialog.
    A better approach would be that QDialog and ColorDialog would have the same parent.

    Checkout the manual for mapToParent() or mapToGlobal()


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.