CUSTOM_METAOBJECT(DeclarativeCheckBox, QCheckBox)
+// DeclarativeDialog
+DeclarativeDialog::DeclarativeDialog(QObject *parent) : DeclarativeWidgetProxy<QDialog>(parent)
+{
+ connectAllSignals(m_proxiedObject, this);
+}
+
+CUSTOM_METAOBJECT(DeclarativeDialog, QDialog)
+
+// DeclarativeDialogButtonBox
+DeclarativeDialogButtonBox::DeclarativeDialogButtonBox(QObject *parent) : DeclarativeWidgetProxy<QDialogButtonBox>(parent)
+{
+ connectAllSignals(m_proxiedObject, this);
+}
+
+CUSTOM_METAOBJECT(DeclarativeDialogButtonBox, QDialogButtonBox)
+
// DeclarativeLabel
DeclarativeLabel::DeclarativeLabel(QObject *parent) : DeclarativeWidgetProxy<QLabel>(parent)
{
QMenuBar *menuBar = qobject_cast<QMenuBar*>(widget);
QToolBar *toolBar = qobject_cast<QToolBar*>(widget);
QStatusBar *statusBar = qobject_cast<QStatusBar*>(widget);
+ QDialog *dialog = qobject_cast<QDialog*>(widget);
if (menuBar) {
m_proxiedObject->setMenuBar(menuBar);
m_proxiedObject->addToolBar(toolBar);
} else if (statusBar) {
m_proxiedObject->setStatusBar(statusBar);
+ } else if (dialog) {
+ // We allow to place dialogs on the mainwindow
+ dialog->setParent(m_proxiedObject, dialog->windowFlags());
} else if (widget) {
if (m_proxiedObject->centralWidget()) {
qmlInfo(declarativeObject) << "The QMainWindow contains a central widget already";
#include <QtGui/QAction>
#include <QtGui/QCalendarWidget>
#include <QtGui/QCheckBox>
+#include <QtGui/QDialog>
+#include <QtGui/QDialogButtonBox>
#include <QtGui/QFormLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
{
Q_UNUSED(declarativeObject);
DeclarativeObjectProxy<T>::m_children.append(declarativeObject);
- widget->setParent(DeclarativeObjectProxy<T>::m_proxiedObject);
+ widget->setParent(DeclarativeObjectProxy<T>::m_proxiedObject, widget->windowFlags());
}
virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject)
DeclarativeCheckBox(QObject *parent = 0);
};
+class DeclarativeDialog : public DeclarativeWidgetProxy<QDialog>
+{
+ DECLARATIVE_OBJECT
+
+ public:
+ DeclarativeDialog(QObject *parent = 0);
+};
+
+class DeclarativeDialogButtonBox : public DeclarativeWidgetProxy<QDialogButtonBox>
+{
+ DECLARATIVE_OBJECT
+
+ public:
+ DeclarativeDialogButtonBox(QObject *parent = 0);
+};
+
class DeclarativeLabel : public DeclarativeWidgetProxy<QLabel>
{
DECLARATIVE_OBJECT
// widgets
qmlRegisterType<DeclarativeCalendarWidget>("QtGui", 1, 0, "CalendarWidget");
qmlRegisterType<DeclarativeCheckBox>("QtGui", 1, 0, "CheckBox");
+ qmlRegisterType<DeclarativeDialog>("QtGui", 1, 0, "Dialog");
+ qmlRegisterType<DeclarativeDialogButtonBox>("QtGui", 1, 0, "DialogButtonBox");
qmlRegisterType<DeclarativeLabel>("QtGui", 1, 0, "Label");
qmlRegisterType<DeclarativeMainWindow>("QtGui", 1, 0, "MainWindow");
qmlRegisterType<DeclarativeMenu>("QtGui", 1, 0, "Menu");
size: Qt.size(500, 300)
+ Dialog {
+ id: myDialog
+
+ size: Qt.size(300, 200)
+ visible: false
+
+ VBoxLayout {
+ Label {
+ text: "Hello World"
+ }
+ DialogButtonBox {
+ standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
+
+ onAccepted: myDialog.accept()
+ onRejected: myDialog.reject()
+ }
+ }
+ }
+
MenuBar {
Menu {
title: qsTr("File")
Action {
text: qsTr("New")
+ onTriggered: {
+ var result = myDialog.exec()
+ console.log("result="+result)
+ }
}
Action {