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

  • Home
  • SEARCH
  • 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 7163171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:51:25+00:00 2026-05-28T13:51:25+00:00

I have a dialog with a big textbox. I want the user to be

  • 0

I have a dialog with a big textbox. I want the user to be able to maximize the dialog. I already tried the following options (XML_Editor is a QDialog instance):

XML_Editor.setWindowFlags(QtCore.Qt.Window or QtCore.Qt.WindowMaximizeButtonHint) — shows the Maximize button but doesn’t center the dialog w.r.t. the parent anymore

XML_Editor.setWindowFlags(QtCore.Qt.Dialog or QtCore.Qt.WindowMaximizeButtonHint or QtCore.Qt.CustomizeWindowHint) — no effect

Now my question is: How do I achieve that the Maximize button is shown and the dialog pops up centered w.r.t. the parent? Most resources on the web seem to focus on how to get rid of the Maximize button. Any ideas how to achieve the opposite?

The main target is Ubuntu 10.04 (default configuration), it would be great if it worked on Windows and Mac, too.

I appreciate any hint. Thanks in advance.

  • 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-28T13:51:26+00:00Added an answer on May 28, 2026 at 1:51 pm

    The various window managers on the main platforms will all behave somewhat differently, so it will be hard to come up with a solution that is 100% guaranteed to work in all cases.

    Using the default windowFlags on Linux KDE produces a dialog with context, maximize, minimize and close buttons; but with Windows XP, there’s only a context and close button.

    For most platforms, it would appear that at least the WindowSystemMenuHint and WindowMaximizeButtonHint flags need to be set in order to ensure the maximize button is present.

    To ensure that the dialog stays centered on the parent window, just pass a reference to the parent in the dialog’s constructor.

    (Note that when combining the flags, you must use the bitwise OR operator |. In your examples, you use the boolean OR operator or, which would select the first non-zero value, but ignore the others).

    The following example produces a centered dialog with maximize button for me on both Linux KDE and Windows XP:

    from PyQt4 import QtGui, QtCore
    
    class Window(QtGui.QWidget):
        def __init__(self):
            QtGui.QWidget.__init__(self)
            self.button = QtGui.QPushButton('Show Dialog', self)
            self.button.clicked.connect(self.handleButton)
            layout = QtGui.QHBoxLayout(self)
            layout.addWidget(self.button)
    
        def handleButton(self):
            dialog = QtGui.QDialog(self)
            dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
            dialog.setWindowFlags(dialog.windowFlags() |
                                  QtCore.Qt.WindowSystemMenuHint |
                                  QtCore.Qt.WindowMinMaxButtonsHint)
            dialog.resize(160, 120)
            dialog.show()
    
    if __name__ == '__main__':
    
        import sys
        app = QtGui.QApplication(sys.argv)
        window = Window()
        window.show()
        window.resize(320, 240)
        sys.exit(app.exec_())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Rather than have everything in one big dialog, I'm looking at being able to
I have a dialog preference with a button on it that I want to
I have a dialog that I want to place within another dialog and position
I have a big container with scrollbars. A modal dialog with jquery UI shall
I'm currently working with Monotouch.Dialog and I have a big list of item. I
I have a big problem: I want control if 3G or WiFi are activated.
Many applications have dialogs which have totally custom-looking dialogs, big fat tool-bars and non-rectangular
I have dialog created like this $('#add_error').click(function(e) { $('<div>') .load('/someaction/format/html/') .dialog({ title: 'Some title',
I have a dialog with this content: <RelativeLayout android:layout_width=wrap_content android:layout_height=wrap_content > <ScrollView android:layout_width=fill_parent android:layout_height=wrap_content
I have a dialog - <div data-role=dialog id=msg-popup> <div data-role=header> <h1>Notification</h1> </div> <div data-role=content

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.