Results 1 to 4 of 4

Thread: setting widget as modal, disables button

  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default setting widget as modal, disables button

    Hi,

    I have written the following code in the constructor of class that reimplements QWidget

    Qt Code:
    1. setAttribute(Qt::WA_DeleteOnClose);
    2. setWindowModality(Qt::WindowModal);
    3. setFixedSize(400,120);
    4. setAutoFillBackground(true);
    5.  
    6. registerButton = new QPushButton(tr("Enter registraion key"),this);
    To copy to clipboard, switch view to plain text mode 

    I am trying to get a modal widget (frameless) on top of my mainwindow. Parent of this widget is the mainwindow of the application. But the registerButton is disabled because of setWindowModal.

    Anyideas on why the button is disabled and how can I prevent it from getting disabled ?

    Thanks a lot

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: setting widget as modal, disables button

    Are you using this code under Windows?

  3. #3
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setting widget as modal, disables button

    yes, I am using this under windows.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: setting widget as modal, disables button

    And if you rem the window modality line then everything works as expected? It could be some kind of bug... Why don't you use a dialog instead of a widget? If you already have a widget, you can always wrap it into a dialog:
    Qt Code:
    1. QDialog dlg;
    2. MyWidget *myWidget = new MyWidget;
    3. l->addWidget(myWidget);
    4. dlg.setLayout(l);
    5. dlg.exec();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 4
    Last Post: 23rd November 2006, 05:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.