Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6900521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:33:22+00:00 2026-05-27T07:33:22+00:00

In my Qt-based application (built using PyQt 4.8.6), I have a class that is

  • 0

In my Qt-based application (built using PyQt 4.8.6), I have a class that is a subclass of QtGui.QDialog:

class ModelDialog(QtGui.QDialog):
    ...

When I run the application’s user interface, I can display the QDialog like so:

def main():
    app = QtGui.QApplication(sys.argv)
    dialog = ModelDialog()
    dialog.exec_()

According to the Qt docs and the PyQt docs, exec_() is a blocking function for this QDialog, which defaults to a modal window (which by definition prevents the user from interacting with any other windows within the application). This is exactly what happens under normal circumstances.

Recently, however, I’ve been working on a way to call through the entire QApplication using defaults for all input values, and not asking the user for any input. The application behaves as expected except for one single aspect: calling dialog.exec_() causes the modal dialog to be shown.

The only workaround I’ve been able to find has been to catch the showEvent function and to promptly hide the window, but this still allows the QDialog object to be shown for a split second:

class ModelDialog(QtGui.QDialog):
    ...
    def showEvent(self, data=None):
        self.hide()

Is there a way to prevent the modal window from being shown altogether, while continuing to block the main event loop? I’d love for there to be something like:

def main():
    app = QtGui.QApplication(sys.argv)
    dialog = ModelDialog()
    dialog.setHideNoMatterWhat(True)
    dialog.exec_()

(to that end, I tried using QWidget.setVisible(False), but dialog.exec_() sets the dialog to be visible anyways, which is expected according to the Qt docs)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:33:23+00:00Added an answer on May 27, 2026 at 7:33 am

    Use app.exec_() instead of dialog.exec_().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a web based application in production built using django. It is deployed
I have a very rich media based application built in WPF, and Im using
I have a web application that needs to be built using PHP/MySQL. The application
I have a Qt-based application that uses a number of dlls that are built
We have a web application that has been built using MySQL / PHP /
We have J2EE application built using Hibernate and struts. We have RMI registry based
I have a spring based web application MyWebapp built using maven and deployed on
I have a cakePhp application built, and now I'm creating a simple blog based
I have a web-based application that notifies users of activity on the site via
I have a UINavigationBar based application - only a one navigation bar that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.