Important: Please read the Qt Code of Conduct -

Modal Dialog does not blocking the user input.

  • Dear Friends,
    I am having one issue regarding the modal dialog. basically it should stop user input. I set the window modality(setWindowModality(Qt::ApplicationModal);) it blocking the mouse click but unable to stop the tab key navigation and you can say keyboard input still i can give.I want to stop both mouse click plus keyborad input when dialog are pop up.Please suggest a solution if you have.


    [Edit ~aha_1980: model -> modal]

  • @Sebastian
    A modal dialog should be stopping any key presses getting through to the window/dialog behind it, as well as mouse clicks.

  • Lifetime Qt Champion

    Can you show the code?
    It should block any interaction with the windows behind it.

  • Actually the scenario is like i have a QWidget(parent) that holds another widget which have the layout in which we have 3 buttons Yes ,No and Cancel. Basicly my requirement is if I am navigating through the tab button then focus should go on Yes,No and Cancel buttons afterwards again in Yes button.I mean it should be cyclic.
    I tried so many things.


    I also tried in evenfilter and overrided the keyEvent->key() == Qt::Key_Tab from there i return the true.So from this i am able to solve my first problem which i posted first but now u want tab focus should be cyclic(Yes,No and Cancel buttons).

    Please advise something i am really stuck.

  • Lifetime Qt Champion

    TabOrder you can set in editor
    alt text

    so make sure the buttons are 1,2,3 and nothing else can take focus.

  • Lifetime Qt Champion


    Why not use a QDialog with QDialogButtonBox ?

Log in to reply