Qt 5.10 Book Examples
chapter60
QMLCPPConnect
main.cpp
Go to the documentation of this file.
1
// ======================================================================
2
// main.cpp
3
// ======================================================================
4
// This file is a part of the book
5
// "Qt 5.10 Professional programming with C++"
6
// http://qt-book.com
7
// ======================================================================
8
// Copyright (c) 2017 by Max Schlee
9
// ======================================================================
10
11
#include <QGuiApplication>
12
#include <QQmlApplicationEngine>
13
#include <QQmlComponent>
14
#include "
CppConnection.h
"
15
16
// ----------------------------------------------------------------------
17
int
main
(
int
argc,
char
** argv)
18
{
19
QGuiApplication app(argc,argv);
20
QQmlApplicationEngine eng;
21
QQmlComponent comp(&eng, QUrl(
"qrc:/main.qml"
));
22
CppConnection
cc;
23
24
QObject* pobj = comp.create();
25
QObject* pcmdQuitButton = pobj->findChild<QObject*>(
"QuitButton"
);
26
if
(pcmdQuitButton) {
27
QObject::connect(pcmdQuitButton, SIGNAL(quitClicked()),
28
&cc, SLOT(slotQuit())
29
);
30
}
31
QObject* pcmdInfoButton = pobj->findChild<QObject*>(
"InfoButton"
);
32
if
(pcmdInfoButton) {
33
QObject::connect(pcmdInfoButton, SIGNAL(infoClicked(QString)),
34
&cc, SLOT(slotInfo(QString))
35
);
36
}
37
38
return
app.exec();
39
}
CppConnection
Definition:
CppConnection.h:15
main
int main(int argc, char **argv)
Definition:
main.cpp:15
CppConnection.h
Generated by
1.8.14