Answer the question
In order to leave comments, you need to log in
A bunch of C++ and QML?
There is a signal in one QML file, it must interact with the C++ part, but the pluses do not find this signal, because the signal must be visible in main.qml. It is necessary in short so that I can normally connect a signal from a QML (not main) file with a slot from C ++. Question: how to do it right?
Answer the question
In order to leave comments, you need to log in
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
qmlRegisterType<Calc>("com.company.calc", 1, 0, "MyCalc");
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
import com.company.calc 1.0
// и имя элемента будет равно третьему параметру
MyCalc {
id: myCalcM
}
Q_PROPERTY(QString str READ string WRITE setString)
Q_PROPERTY(double getResult READ StartAnalize_GetResult)
function getResult()
{
myCalcM.str = allStr()
return myCalcM.getResult;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question