Results 1 to 20 of 21

Thread: enabling/disabling a QMainWindow?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: enabling/disabling a QMainWindow?

    Quote Originally Posted by TheRonin View Post
    The signal i emit leads to a slot that does some things before issuing a qApp->quit().
    Have you tried commenting out this signal emission? BTW If you issue a "qApp->quit()" your app should actually get closed and not disabled or am I missing something?
    Current Qt projects : QCodeEdit, RotiDeCode

  2. #2
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: enabling/disabling a QMainWindow?

    hey guys, thanks for your help thus far...i hope there's a solution right around the corner!

    Quote Originally Posted by wysota View Post
    I don't think this is the case but you may just try with another widget style and see for yourself.
    I get the desired behavior if instead of disabling the QMainWindow i disable the root widget (a QWidget called centralwidget by the designer). I would of course like to not need to do that sort of work-around instead of working with the mainwindow directly. Had you been able to reproduce my problem i would have been tempted to call it a bug of sorts but since i seem to be the only one affected, maybe it's due to a problem with my Qt installation??

    Quote Originally Posted by fullmetalcoder View Post
    Have you tried commenting out this signal emission? BTW If you issue a "qApp->quit()" your app should actually get closed and not disabled or am I missing something?
    I just tried skipping the signal emission like you suggested but the mainwindow still doesn't get disabled (unless i disable the centralwidget). You're absolutely right about the quit() terminating the application but there is a significant amount of time between the emission of the signal and the actual call to quit() (i do a bunch of stuff in-between that takes time...like closing tcp connections and saving things to file.)

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

    Default Re: enabling/disabling a QMainWindow?

    Could you prepare a minimal compilable example reproducing the problem?

  4. #4
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: enabling/disabling a QMainWindow?

    Quote Originally Posted by wysota View Post
    Could you prepare a minimal compilable example reproducing the problem?
    Sorry for the delayed response...here comes the 'minimal' example. When run on my system the main window does not become disabled unless i use the centralwidget-object

    Qt Code:
    1. #include <iostream>
    2. #include <QApplication>
    3. #include <QMainWindow>
    4. #include <QWidget>
    5. #include <QPushButton>
    6. #include <QString>
    7. //#include <QRect>
    8. //#include <QSize>
    9. //
    10. using namespace std;
    11. //
    12. class Gui : public QMainWindow
    13. {
    14. Q_OBJECT
    15. public:
    16. Gui( QWidget * parent = 0 );
    17. private slots:
    18. void disableMe();
    19. private:
    20. QWidget *centralwidget;
    21. QPushButton *pushButton;
    22. };
    23.  
    24. int main(int argc, char ** argv)
    25. {
    26. QApplication app( argc, argv );
    27. Gui gui;
    28. gui.show();
    29. app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
    30. return app.exec();
    31. }
    32.  
    33. Gui::Gui( QWidget * parent ) : QMainWindow(parent)
    34. {
    35. this->setObjectName(QString::fromUtf8("MainWindow"));
    36. this->setWindowTitle("main window test");
    37. centralwidget = new QWidget(this);
    38. centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    39. pushButton = new QPushButton(centralwidget);
    40. pushButton->setObjectName(QString::fromUtf8("pushButton"));
    41. pushButton->setGeometry(QRect(110, 50, 101, 41));
    42. pushButton->setText("disable?");
    43. this->setCentralWidget(centralwidget);
    44.  
    45. QSize size(322, 149);
    46. size = size.expandedTo(this->minimumSizeHint());
    47. this->resize(size);
    48.  
    49. connect(pushButton, SIGNAL(clicked()),
    50. this, SLOT(disableMe()));
    51. }
    52.  
    53. void Gui::disableMe()
    54. {
    55. cout << "trying to disable the mainwindow...";
    56. this->setDisabled(true);
    57. cout << "success?" << endl;
    58. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: enabling/disabling a QMainWindow?

    Seems to work fine for me (Linux+4.2.3+Plastique). Works well on CDE and Cleanlooks as well.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: enabling/disabling a QMainWindow?

    And works for me on Qt4.2.3/Win with both, winxp and windows styles too.
    J-P Nurmi

  7. #7
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: enabling/disabling a QMainWindow?

    Quote Originally Posted by wysota View Post
    Seems to work fine for me (Linux+4.2.3+Plastique). Works well on CDE and Cleanlooks as well.
    Quote Originally Posted by jpn View Post
    And works for me on Qt4.2.3/Win with both, winxp and windows styles too.
    You're kidding!? Haha, that is too weird. Things are pointing more and more towards there being a problem with my installation. I just can't see any other reason for the behavior.

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

    Default Re: enabling/disabling a QMainWindow?

    Did the code I pasted at the beginning of the thread work for you?

  9. #9
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: enabling/disabling a QMainWindow?

    Quote Originally Posted by wysota View Post
    Did the code I pasted at the beginning of the thread work for you?
    no luck there either unfortunately

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

    Default Re: enabling/disabling a QMainWindow?

    Oh, you could have said so earlier.. From what you said I understood it had worked.

  11. #11
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: enabling/disabling a QMainWindow?

    Quote Originally Posted by wysota View Post
    Oh, you could have said so earlier.. From what you said I understood it had worked.
    I'm sorry, i should have been more clear. What i meant was that the example works if i disable the centralwidget instead of trying to disable the mainwindow. This is a little easier in my example since i there have direct access to the centralwidget. In either case, i shouldn't have to though, hence the annoyance.

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

    Default Re: enabling/disabling a QMainWindow?

    What is your exact work environment? Platform, Qt version (compiled/binary), toolchain...?

Similar Threads

  1. QMainWindow Maximization Issue
    By vishal.chauhan in forum Qt Programming
    Replies: 6
    Last Post: 15th March 2007, 13:30
  2. How do I add a QGridlayout in a QMainwindow?
    By Teuniz in forum Qt Programming
    Replies: 4
    Last Post: 14th February 2007, 10:18
  3. Dynamically Loading a QMainWindow?
    By natron in forum Newbie
    Replies: 10
    Last Post: 21st July 2006, 01:15
  4. Insert separate QToolBar into QMainWindow
    By YuriyRusinov in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 10:37
  5. Replies: 18
    Last Post: 22nd February 2006, 20:51

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
  •  
Qt is a trademark of The Qt Company.