Results 1 to 2 of 2

Thread: Is this a bug?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Is this a bug?

    On application startup I create a QMenu then after I create a QWidget alll within the constructor. By createing a QWidget the menu becomes disabled. If the QWidget is created after calling show() everything is fine.
    I'm using the commercial version of 4.4.1 installed as is, not rebuilt, and building the project in Visual Studio 2008. I checked my Mac version and it works correctly, but I have done a local rebuild on the Mac.

    The code ....

    Qt Code:
    1. #ifndef QTAPPLICATION_H
    2. #define QTAPPLICATION_H
    3.  
    4. #include <QtGui/QApplication>
    5. #include <QtGui/QMainWindow>
    6. #include <QtGui/QWidget>
    7. #include <QtGui/QAction>
    8. #include <QtGui/QMenu>
    9. #include <QtGui/QMenuBar>
    10.  
    11. class QTApplication : public QMainWindow
    12. {
    13. Q_OBJECT
    14.  
    15. public:
    16. QTApplication(QWidget *parent = 0, Qt::WFlags flags = 0);
    17. virtual ~QTApplication();
    18. };
    19.  
    20. #endif // QTAPPLICATION_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "qtapplication.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. QTApplication w;
    8. w.show();
    9. return a.exec();
    10. }
    11.  
    12.  
    13. QTApplication::QTApplication(QWidget *parent, Qt::WFlags flags)
    14. : QMainWindow(parent, flags)
    15. {
    16. if (this->objectName().isEmpty())
    17. this->setObjectName(QString::fromUtf8("QTApplicationClass"));
    18.  
    19. this->setWindowTitle(QApplication::translate("QTApplicationClass", "Qt Application", 0, QApplication::UnicodeUTF8));
    20.  
    21. QMenu* menu = menuBar()->addMenu( tr("File") );
    22. menu->addAction( new QAction(tr("exit"), this) );
    23.  
    24. // **** Creating this widget is blocking the menu
    25. QWidget* widget = new QWidget(this);
    26. }
    27.  
    28. QTApplication::~QTApplication()
    29. {
    30. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 16th September 2008 at 07:14. Reason: missing [code] tags

Tags for this Thread

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.