r19004 by craig - Something like working QML Spinboxes

scribus-commit scribus-commit at lists.scribus.net
Sat Apr 5 07:54:48 UTC 2014


Author: craig
Date: Sat Apr  5 07:54:48 2014
New Revision: 19004

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19004
Log:
Something like working QML Spinboxes

Modified:
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribus.h
    trunk/Scribus/scribus/ui/qml/qtq_test1.qml

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19004&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sat Apr  5 07:54:48 2014
@@ -55,6 +55,8 @@
 #include <QQuickView>
 #include <QQmlEngine>
 #include <QQmlComponent>
+#include <QQuickItem>
+#include <QQmlProperty>
 //>>
 #include <QRegExp>
 #include <QScopedPointer>
@@ -10863,32 +10865,49 @@
 
 void ScribusMainWindow::testQTQuick2_1()
 {
-
 	qDebug()<<"Testing Qt Quick 2.0";
 
-	QQuickView *qqview = new QQuickView();
-	qqview->resize(300,200);
-	//QDialog d(this);
-	//QHBoxLayout *layout = new QHBoxLayout(&d);
-	//QWidget *container = createWindowContainer(view);
-	//d.setMinimumSize(200, 200);
-	//d.setMaximumSize(400, 400);
-	//d.setFocusPolicy(Qt::TabFocus);
-
+	qqview = new QQuickView();
 	qqview->setSource(QUrl::fromLocalFile(ScPaths::instance().qmlDir() + "qtq_test1.qml"));
-
-	//	QObject *object = qqv.rootObject();
-	//layout->addWidget(container);
-	//d.exec();
-
-	//container->deleteLater();
-	//layout->deleteLater();
-
 	qqview->setFlags(Qt::Tool);
+	qqview->setResizeMode(QQuickView::SizeViewToRootObject);
+	QObject *rootObject = dynamic_cast<QObject*>(qqview->rootObject());
+	QObject *q_closeCheckBox = rootObject->findChild<QObject*>("closeCheckBox");
+	QObject *q_xSpinBox = rootObject->findChild<QObject*>("xSpinBox");
+	QObject *q_ySpinBox = rootObject->findChild<QObject*>("ySpinBox");
+
+
+	connect(q_xSpinBox, SIGNAL(editingFinished()), this, SLOT(testQT_slot4()));
+	connect(q_ySpinBox, SIGNAL(valueChanged(int)), this, SLOT(testQT_slot3(int)));
+	connect(q_closeCheckBox, SIGNAL(clicked()), this, SLOT(testQT_slot4()));
 	qqview->show();
 
-//	qDebug() << "Property value:" << QQmlProperty::read(object, "someNumber").toInt();
-
+}
+
+void ScribusMainWindow::testQT_slot1(QString s)
+{
+	qDebug()<<"Signal data:"<<s;
+}
+
+void ScribusMainWindow::testQT_slot2(double d)
+{
+	qDebug()<<"Signal data:"<<d;
+}
+
+void ScribusMainWindow::testQT_slot3(int i)
+{
+	qDebug()<<"Signal data:"<<i;
+}
+
+void ScribusMainWindow::testQT_slot4()
+{
+	qDebug()<<"Signal data empty but received";
+	QObject *rootObject = dynamic_cast<QObject*>(qqview->rootObject());
+	QObject *q_xSpinBox = rootObject->findChild<QObject*>("xSpinBox");
+	//if (q_xSpinBox==sender())
+	{
+		qDebug()<<"qov"<<q_xSpinBox->property("value").toDouble();
+	}
 }
 
 void ScribusMainWindow::adjustCMS()

Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19004&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Sat Apr  5 07:54:48 2014
@@ -40,6 +40,7 @@
 #include <QPixmap>
 #include <QPointer>
 #include <QProcess>
+#include <QQuickView>
 #include <QString>
 
 class QCloseEvent;
@@ -571,6 +572,10 @@
 	void slotUpdateMarks();
 	bool editMarkDlg(Mark *mrk, PageItem_TextFrame* currItem = NULL);
 	void testQTQuick2_1();
+	void testQT_slot1(QString);
+	void testQT_slot2(double);
+	void testQT_slot3(int);
+	void testQT_slot4();
 	void adjustCMS();
 	void changePreviewQuality(int index);
 
@@ -674,6 +679,8 @@
 	int m_marksCount; //remember marks count from last call
 	bool m_WasAutoSave;
 	bool m_pagePalVisible;
+
+	QQuickView *qqview;
 };
 
 #endif

Modified: trunk/Scribus/scribus/ui/qml/qtq_test1.qml
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19004&path=/trunk/Scribus/scribus/ui/qml/qtq_test1.qml
==============================================================================
--- trunk/Scribus/scribus/ui/qml/qtq_test1.qml (original)
+++ trunk/Scribus/scribus/ui/qml/qtq_test1.qml Sat Apr  5 07:54:48 2014
@@ -104,6 +104,7 @@
         }
         SpinBox {
             id: xSpinBox
+            objectName: "xSpinBox"
             x: 25
             y: 3
             font.pixelSize: 10
@@ -127,6 +128,7 @@
         }
         SpinBox {
             id: ySpinBox
+            objectName: "ySpinBox"
             x: 25
             y: 23
             font.pixelSize: 10
@@ -150,6 +152,7 @@
         }
         SpinBox {
             id: wSpinBox
+            objectName: "wSpinBox"
             x: 125
             y: 3
             font.pixelSize: 10
@@ -173,6 +176,7 @@
         }
         SpinBox {
             id: hSpinBox
+            objectName: "wSpinBox"
             x: 125
             y: 23
             font.pixelSize: 10
@@ -202,12 +206,11 @@
 
     }
 
-
-
     CheckBox {
         x: 204
         y: 110
-        text: "Close"
+        objectName: "closeCheckBox"
+
         style: CheckBoxStyle {
             indicator: Rectangle {
                     implicitWidth: 10
@@ -231,8 +234,5 @@
                 color: "red"
             }
         }
-        onClicked: {
-            Qt.close();
-        }
     }
 }




More information about the scribus-commit mailing list