我正在制作一个程序,我需要用户填写一些信息。我有我的main.qml菜单和我的页面SubPage.qml,用户可以访问该表单来填充它。
现在表单已填满,我想将信息发送到main.cpp来处理它。 我所有的尝试都没有成功......
这里是我的main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlComponent>
#include <QQuickView>
#include <QtQml>
#include <QDebug>
#include "generalsettings.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QQmlApplicationEngine engine2;
GeneralSettings generalSettings1;
QQmlComponent component(&engine2, QUrl((QStringLiteral("qrc:/SubPage.qml"))));
QObject *element = engine.rootObjects().value(0);
//QQuickWindow *window = qobject_cast<QQuickWindow *>(element);
QObject::connect(component, SIGNAL(saveGeneralSettings(QString)),
&generalSettings1, SLOT(registerGeneralSettings(QString)));
return app.exec();
}
我的SubPage.qml 我只把按钮带有信号
Button{
id:buttonRight
text:"Right"
anchors.margins: 10
x:visualConditionsContainer.x + maxCardWidth/2 - buttonRight.width + visualConditionsContainer.width/2
y:maxCardHeight +visualConditionsContainer.y +40
onClicked:{
if(datePickerContainer.x != pageGeneralSettings.width){
selectedCard = datePickerContainer
if(currentTimeDate.checked){
timePickerContainer.x = pageGeneralSettings.width
}
animateGoRight.start()
}else if(timePickerContainer.x != pageGeneralSettings.width){
selectedCard = timePickerContainer
animateGoRight.start()
}else if(globalConfigContainer.x != pageGeneralSettings.width){
selectedCard = globalConfigContainer
animateGoRight.start()
}else if(visualConditionsContainer.x != pageGeneralSettings.width){
pageStack.push(Qt.resolvedUrl("PageModifications.qml"))
DataManager.registerGeneralSettings(currentTimeDate.checked,Qt.formatDate(datePicker.selectedDate, "d MMMM yyyy"),Qt.formatTime(timePicker.getCurrentTime(), "hh:mm:ss"), dayDurationTextField.text,isFarCulling.checked, isEnableLensFlare.checked,radioButton(rateReflection.current.text), sliderVisibility.value, sliderLight.value, sliderTurbidity.value )
pageGeneralSettings.saveGeneralSettings("coucou c'est QML")
}
}
backgroundColor: Theme.accentColor
}
谢谢你的帮助