Now that Ubuntu finally has Qt 5.2, I’m playing with Qt Quick Components, and right now I’m having issues trying to get the menu bar to show, when I try to implement the menubar I get this message:
appmenu-qt: handleReparent 128 The given QWindow has no QMenuBar assigned
This is how I’m launching my Qml from C++:
// First initialize Qt Application
QGuiApplication app(argc, argv);
// Second initialize config singleton
Config::init();
QQmlApplicationEngine engine;
engine.load(QUrl::fromLocalFile(config->getBinDir() + "/qml/main.qml"));
QObject *topLevel = engine.rootObjects().value(0);
QQuickWindow *mainWindow = qobject_cast<QQuickWindow*>(topLevel);
mainWindow->show();
return app.exec();
And this is the Qml I have so far:
import QtQuick.Controls 1.1
import QtQuick.Dialogs 1.1
import QtQuick 2.2
ApplicationWindow {
visible: true
width: 640
height: 480
minimumWidth: 400
minimumHeight: 300
title: "MyApp"
// Actions for menu items
Item {
id: globalActions
Action {
id: quitAction
text: i18n.tr("Quit");
onTriggered: Qt.quit();
}
Action {
id: prefAction
text: i18n.tr("Preferences");
//onTriggered: TODO - LAUNCH PREFERENCES
}
Action {
id: aboutAction
text: i18n.tr("About");
//onTriggered: TODO - LAUNCH ABOUT
}
}
MessageDialog {
id: aboutBox
title: "MyApp"
text: "This is a test app for Qt Quick Components"
icon: StandardIcon.Information
}
menuBar: MenuBar {
Menu {
title: "&File"
MenuItem { action: quitAction }
}
Menu {
title: "&Edit"
MenuItem { action: prefAction }
}
Menu {
title: "&Help"
MenuItem { action: aboutAction }
}
}
}
↧