Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quick-nested-event-loop
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yuya Nishihara
quick-nested-event-loop
Commits
e7e600d5
Commit
e7e600d5
authored
4 years ago
by
Yuya Nishihara
Browse files
Options
Downloads
Patches
Plain Diff
add service object that spins new event loop with message box
parent
d1bb93c4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+8
-3
8 additions, 3 deletions
CMakeLists.txt
helloservice.cpp
+12
-0
12 additions, 0 deletions
helloservice.cpp
helloservice.h
+17
-0
17 additions, 0 deletions
helloservice.h
main.cpp
+12
-2
12 additions, 2 deletions
main.cpp
with
49 additions
and
5 deletions
CMakeLists.txt
+
8
−
3
View file @
e7e600d5
...
...
@@ -11,10 +11,12 @@ set(CMAKE_AUTORCC ON)
set
(
CMAKE_CXX_STANDARD 14
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
find_package
(
QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED
)
find_package
(
Qt
${
QT_VERSION_MAJOR
}
COMPONENTS Core Quick REQUIRED
)
find_package
(
QT NAMES Qt6 Qt5 COMPONENTS Core Quick
Widgets
REQUIRED
)
find_package
(
Qt
${
QT_VERSION_MAJOR
}
COMPONENTS Core Quick
Widgets
REQUIRED
)
add_executable
(
quick-nested-event-loop
helloservice.cpp
helloservice.h
main.cpp
qml.qrc
)
...
...
@@ -22,4 +24,7 @@ add_executable(quick-nested-event-loop
target_compile_definitions
(
quick-nested-event-loop
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>
)
target_link_libraries
(
quick-nested-event-loop
PRIVATE Qt
${
QT_VERSION_MAJOR
}
::Core Qt
${
QT_VERSION_MAJOR
}
::Quick
)
PRIVATE
Qt
${
QT_VERSION_MAJOR
}
::Core
Qt
${
QT_VERSION_MAJOR
}
::Quick
Qt
${
QT_VERSION_MAJOR
}
::Widgets
)
This diff is collapsed.
Click to expand it.
helloservice.cpp
0 → 100644
+
12
−
0
View file @
e7e600d5
#include
<QMessageBox>
#include
"helloservice.h"
HelloService
::
HelloService
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
void
HelloService
::
greeting
()
const
{
QMessageBox
dlg
(
QMessageBox
::
NoIcon
,
tr
(
"Hello world!"
),
tr
(
"Hello world!"
));
dlg
.
exec
();
}
This diff is collapsed.
Click to expand it.
helloservice.h
0 → 100644
+
17
−
0
View file @
e7e600d5
#ifndef HELLOSERVICE_H
#define HELLOSERVICE_H
#include
<QObject>
#include
<QString>
class
HelloService
:
public
QObject
{
Q_OBJECT
public:
explicit
HelloService
(
QObject
*
parent
=
nullptr
);
Q_INVOKABLE
void
greeting
()
const
;
};
#endif // HELLOSERVICE_H
This diff is collapsed.
Click to expand it.
main.cpp
+
12
−
2
View file @
e7e600d5
#include
<Q
Gui
Application>
#include
<QApplication>
#include
<QQmlApplicationEngine>
#include
<QQmlContext>
#include
<QVariant>
#include
<QVector>
#include
"helloservice.h"
int
main
(
int
argc
,
char
*
argv
[])
{
QCoreApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
);
Q
Gui
Application
app
(
argc
,
argv
);
QApplication
app
(
argc
,
argv
);
HelloService
service
;
QQmlApplicationEngine
engine
;
auto
*
context
=
engine
.
rootContext
();
context
->
setContextProperties
({
{
QStringLiteral
(
"serviceObject"
),
QVariant
::
fromValue
(
&
service
)},
});
const
QUrl
url
(
QStringLiteral
(
"qrc:/main.qml"
));
QObject
::
connect
(
&
engine
,
&
QQmlApplicationEngine
::
objectCreated
,
&
app
,
[
url
](
QObject
*
obj
,
const
QUrl
&
objUrl
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment