Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDialog malfunction in modality mode



  • Hi everyone!
    I want to create a child widget with option to block parent widget.
    Many advise to create QDialog with exec_ method and I tried that.
    I even tried to set setWindowModality(QtCore.Qt.ApplicationModal)
    As result the child widget is always on top of parent, but if I click on parent the child loses his focus. And the parent widget still can be moved on screen or even minimized in trey.
    What's the point of such modality if it's not block parent absolutely?
    Qt 4.8


  • Lifetime Qt Champion

    @Buccaneer
    Hi
    When you create your dialog, do you give the parent in the constructor ?
    Dialog mydia( Parent );
    Also, did you call QDialog constructor from your class?
    MyDialog::MyDialog(QWidget *parent) :..
    QDialog(parent),
    So the flags get set ?



  • @mrjj
    I make my project in python with PyQt
    No I didn't set parent.
    When My QDialog class starts - parent is set to None

    I just ported the project from ubuntu to windows and modality works perfectly (((
    Looks like this is my problem in ubuntu + PyQt4
    I'm so upset


  • Lifetime Qt Champion

    @Buccaneer
    Hi, sorry, though it was c++.
    Never used Py so Have no idea.

    I assume, your dialog is something like :

    class DateDialog(QDialog):
    def init(self, parent = None):
    super(DateDialog, self).init(parent)

    which as far as I understand will call QDialog Constructor ?

    update: Ah, works in win.



  • @mrjj
    You are absolutely right with code.
    And yeh ((( its work in win... Whyyyyyyyyyyyyy?


  • Lifetime Qt Champion

    @Buccaneer
    Well seems to be the same with C++.
    Looks Modal but can still minimize Parent...
    So I guess it how Ubuntu does "modal"
    Prevents access to any control on the parent but not minimize/maxi.

    Strange.

    Update:
    Seems like other apps have this too. I guess its up to the windows
    manager how it works.


Log in to reply