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 ....
#ifndef QTAPPLICATION_H
#define QTAPPLICATION_H
#include <QtGui/QApplication>
#include <QtGui/QMainWindow>
#include <QtGui/QWidget>
#include <QtGui/QAction>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
{
Q_OBJECT
public:
QTApplication
(QWidget *parent
= 0, Qt
::WFlags flags
= 0);
virtual ~QTApplication();
};
#endif // QTAPPLICATION_H
#ifndef QTAPPLICATION_H
#define QTAPPLICATION_H
#include <QtGui/QApplication>
#include <QtGui/QMainWindow>
#include <QtGui/QWidget>
#include <QtGui/QAction>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
class QTApplication : public QMainWindow
{
Q_OBJECT
public:
QTApplication(QWidget *parent = 0, Qt::WFlags flags = 0);
virtual ~QTApplication();
};
#endif // QTAPPLICATION_H
To copy to clipboard, switch view to plain text mode
#include <QtGui/QApplication>
#include "qtapplication.h"
int main(int argc, char *argv[])
{
QTApplication w;
w.show();
return a.exec();
}
QTApplication
::QTApplication(QWidget *parent, Qt
::WFlags flags
){
if (this->objectName().isEmpty())
this
->setObjectName
(QString::fromUtf8("QTApplicationClass"));
QMenu* menu
= menuBar
()->addMenu
( tr
("File") );
menu
->addAction
( new QAction(tr
("exit"),
this) );
// **** Creating this widget is blocking the menu
}
QTApplication::~QTApplication()
{
}
#include <QtGui/QApplication>
#include "qtapplication.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTApplication w;
w.show();
return a.exec();
}
QTApplication::QTApplication(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
if (this->objectName().isEmpty())
this->setObjectName(QString::fromUtf8("QTApplicationClass"));
this->setWindowTitle(QApplication::translate("QTApplicationClass", "Qt Application", 0, QApplication::UnicodeUTF8));
QMenu* menu = menuBar()->addMenu( tr("File") );
menu->addAction( new QAction(tr("exit"), this) );
// **** Creating this widget is blocking the menu
QWidget* widget = new QWidget(this);
}
QTApplication::~QTApplication()
{
}
To copy to clipboard, switch view to plain text mode
Bookmarks