[PROBLEM]::can't find a way to cooperate with .cpp file
-
I want to be able to change the text, of text edits in my qml file, from my .cpp file; and the values of variables in my .cpp file, from the mouse areas in my qml file... Yet i can't seem to be able to find a way to do this.
main.cpp:
@
#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"Q_DECL_EXPORT int main(int argc, char *argv[])
{
int p1pts;
int p2pts;
int p1unaddedpts;
int p2unaddedpts;
QScopedPointer<QApplication> app(createApplication(argc, argv));QmlApplicationViewer viewer; viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait); viewer.setMainQmlFile(QLatin1String("qml/counter/main.qml")); viewer.showExpanded(); return app->exec();
}
@ -
main.qml:
@
import QtQuick 1.1Rectangle {
width: 360
height: 640
color: "#000000"
border.color: "#000000"
property int p1pts: 20;
property int p2pts: 20;
MouseArea {
id: mousearea1
x: 0
y: 0
width: 360
height: 640
clip: true
smooth: true
hoverEnabled: false
anchors.rightMargin: 0
anchors.bottomMargin: 0
anchors.topMargin: 0
anchors.leftMargin: 0
anchors.fill: parent
onClicked: {
}Rectangle { id: add1 x: 48 y: 180 width: 25 height: 25 color: "#33ff33" radius: 4 MouseArea { id: mouse_area1 anchors.fill: parent } } Rectangle { id: subtract1 x: 103 y: 180 width: 25 height: 25 color: "#ff3333" radius: 4 MouseArea { id: mouse_area2 anchors.fill: parent } } Rectangle { id: add2 x: 236 y: 180 width: 25 height: 25 color: "#33ff33" radius: 4 MouseArea { id: mouse_area3 anchors.fill: parent } } Rectangle { id: subtract2 x: 291 y: 180 width: 25 height: 25 color: "#ff3333" radius: 4 MouseArea { id: mouse_area4 anchors.fill: parent } } Rectangle { id: rectangle1 x: 48 y: 30 width: 80 height: 40 color: "#3333ff" TextEdit { id: text_edit1 x: 0 y: 0 width: 80 height: 40 color: "#ffffff" text: "20" horizontalAlignment: TextEdit.AlignHCenter font.pixelSize: 30 } } Rectangle { id: rectangle2 x: 236 y: 30 width: 80 height: 40 color: "#3333ff" TextEdit { id: text_edit2 x: 0 y: 0 width: 80 height: 40 color: "#ffffff" text: "20" horizontalAlignment: TextEdit.AlignHCenter font.pixelSize: 30 } } Rectangle { id: rectangle3 x: 48 y: 111 width: 80 height: 30 color: "#00ffef" TextEdit { id: text_edit3 x: 0 y: 0 width: 80 height: 30 color: "#ffffff" text: "0" horizontalAlignment: TextEdit.AlignHCenter font.pixelSize: 25 } }
@
-
the remaining .qml file:
@Rectangle { id: rectangle4 x: 236 y: 111 width: 80 height: 30 color: "#00ffef" TextEdit { id: text_edit4 x: 0 y: 0 width: 80 height: 30 color: "#ffffff" text: "0" horizontalAlignment: TextEdit.AlignHCenter font.pixelSize: 25 } } Rectangle { id: rectangle5 x: 48 y: 234 width: 25 height: 25 color: "#ffffff" Text { id: text1 text: qsTr("+") font.bold: true horizontalAlignment: Text.AlignHCenter anchors.fill: parent font.pixelSize: 20 } MouseArea { id: mouse_area5 anchors.fill: parent } } Rectangle { id: rectangle6 x: 103 y: 234 width: 25 height: 25 color: "#ffffff" Text { id: text2 text: qsTr("-") horizontalAlignment: Text.AlignHCenter anchors.fill: parent font.bold: true font.pixelSize: 20 } MouseArea { id: mouse_area6 anchors.fill: parent } } Rectangle { id: rectangle7 x: 236 y: 234 width: 25 height: 25 color: "#ffffff" Text { id: text3 text: qsTr("+") anchors.fill: parent horizontalAlignment: Text.AlignHCenter font.bold: true font.pixelSize: 20 } MouseArea { id: mouse_area7 anchors.fill: parent } } Rectangle { id: rectangle8 x: 291 y: 234 width: 25 height: 25 color: "#ffffff" Text { id: text4 text: qsTr("-") anchors.fill: parent font.bold: true horizontalAlignment: Text.AlignHCenter font.pixelSize: 20 } MouseArea { id: mouse_area8 anchors.fill: parent } } Rectangle { id: rectangle9 color: "#8f0000" anchors.top: parent.top anchors.topMargin: 555 anchors.right: parent.right anchors.rightMargin: 100 anchors.left: parent.left anchors.leftMargin: 100 anchors.bottom: parent.bottom anchors.bottomMargin: 40 Text { id: text5 color: "#0000ff" text: qsTr("EXIT") font.bold: true horizontalAlignment: Text.AlignHCenter anchors.fill: parent font.pixelSize: 34 } MouseArea { id: mouse_area9 anchors.fill: parent onClicked: { Qt.quit(); } } } }
}
@ -
Someone please help me... I can't find the solution anywhere...
-
-
thank you SO MUCH!!!