├── README.md ├── 8.Dbus ├── 2-signals_slots │ ├── 2-signals_slots.pro │ ├── build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug │ │ ├── debug │ │ │ ├── main.o │ │ │ ├── widget.o │ │ │ ├── Client.exe │ │ │ ├── moc_widget.o │ │ │ ├── calculatorINterface.o │ │ │ └── moc_calculatorINterface.o │ │ └── .qmake.stash │ ├── build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug │ │ ├── debug │ │ │ ├── main.o │ │ │ ├── widget.o │ │ │ ├── Server.exe │ │ │ ├── moc_widget.o │ │ │ ├── slavecalculator.o │ │ │ ├── calculatoradaptor.o │ │ │ ├── moc_calculatoradaptor.o │ │ │ └── moc_slavecalculator.o │ │ └── .qmake.stash │ ├── Client │ │ ├── main.cpp │ │ ├── slavecalculator.xml │ │ └── calculatorINterface.cpp │ └── Server │ │ ├── main.cpp │ │ ├── slavecalculator.cpp │ │ ├── slavecalculator.h │ │ ├── widget.h │ │ ├── widget.ui │ │ ├── slavecalculator.xml │ │ └── widget.cpp ├── 3-DbusMessages │ ├── 3-DbusMessages.pro │ ├── build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug │ │ ├── debug │ │ │ ├── main.o │ │ │ ├── widget.o │ │ │ ├── Client.exe │ │ │ └── moc_widget.o │ │ └── .qmake.stash │ ├── Client │ │ ├── main.cpp │ │ ├── slavecalculator.xml │ │ └── calculatorINterface.cpp │ └── Server │ │ ├── main.cpp │ │ ├── slavecalculator.cpp │ │ ├── slavecalculator.h │ │ ├── widget.h │ │ ├── widget.ui │ │ └── slavecalculator.xml ├── 4-DBusInterface │ ├── 4-DBusInterface.pro │ ├── build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug │ │ ├── debug │ │ │ ├── main.o │ │ │ ├── widget.o │ │ │ ├── Client.exe │ │ │ └── moc_widget.o │ │ └── .qmake.stash │ ├── Client │ │ ├── main.cpp │ │ ├── slavecalculator.xml │ │ ├── calculatorINterface.cpp │ │ └── Client.pro │ └── Server │ │ ├── main.cpp │ │ ├── slavecalculator.cpp │ │ ├── slavecalculator.h │ │ ├── widget.h │ │ ├── widget.ui │ │ ├── slavecalculator.xml │ │ └── widget.cpp └── 1.clientServer │ ├── clientserver │ ├── clientserver.pro │ ├── build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug │ │ ├── debug │ │ │ ├── main.o │ │ │ ├── widget.o │ │ │ ├── Client.exe │ │ │ ├── moc_widget.o │ │ │ ├── calculatorInterface.o │ │ │ └── moc_calculatorInterface.o │ │ └── .qmake.stash │ ├── build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug │ │ ├── debug │ │ │ ├── main.o │ │ │ ├── widget.o │ │ │ ├── Server.exe │ │ │ ├── moc_widget.o │ │ │ ├── slavecalculator.o │ │ │ ├── calculatoradaptor.o │ │ │ ├── moc_slavecalculator.o │ │ │ └── moc_calculatoradaptor.o │ │ └── .qmake.stash │ ├── Client │ │ ├── main.cpp │ │ ├── slavecalculator.xml │ │ ├── calculatorInterface.cpp │ │ ├── widget.cpp │ │ └── widget.h │ └── Server │ │ ├── main.cpp │ │ ├── slavecalculator.cpp │ │ ├── slavecalculator.h │ │ ├── slavecalculator.xml │ │ ├── widget.ui │ │ └── widget.cpp │ ├── build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug │ ├── Client │ │ ├── Client │ │ ├── main.o │ │ ├── widget.o │ │ ├── moc_widget.o │ │ ├── calculatorInterface.o │ │ └── moc_calculatorInterface.o │ ├── Server │ │ ├── Server │ │ ├── main.o │ │ ├── widget.o │ │ ├── moc_widget.o │ │ ├── slavecalculator.o │ │ ├── calculatoradaptor.o │ │ ├── moc_slavecalculator.o │ │ ├── moc_calculatoradaptor.o │ │ └── .qmake.stash │ └── .qmake.stash │ └── build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug │ ├── Client │ └── debug │ │ ├── main.o │ │ ├── widget.o │ │ ├── Client.exe │ │ ├── moc_widget.o │ │ ├── calculatorInterface.o │ │ └── moc_calculatorInterface.o │ ├── Server │ └── debug │ │ ├── main.o │ │ ├── widget.o │ │ ├── Server.exe │ │ ├── moc_widget.o │ │ ├── slavecalculator.o │ │ ├── calculatoradaptor.o │ │ ├── moc_slavecalculator.o │ │ └── moc_calculatoradaptor.o │ └── .qmake.stash ├── 7.IPC ├── 7-3TcpClient │ ├── main.cpp │ ├── widget.h │ ├── widget.ui │ ├── widget.cpp │ └── 7-3TcpClient.pro ├── 7-3TcpServer │ ├── main.cpp │ ├── widget.h │ ├── widget.ui │ ├── widget.cpp │ └── 7-3TcpServer.pro ├── 7-2SharedMemory │ ├── main.cpp │ ├── widget.h │ └── 7-2SharedMemory.pro ├── 7-4FileConsumer │ ├── main.cpp │ ├── widget.h │ ├── widget.ui │ └── 7-4FileConsumer.pro └── 7-4FileProducer │ ├── main.cpp │ ├── widget.h │ ├── widget.cpp │ ├── widget.ui │ └── 7-4FileProducer.pro ├── 6.QProcess └── 6-1QProcess │ ├── main.cpp │ ├── widget.h │ ├── widget.cpp │ └── 6-1QProcess.pro ├── 2.CreatingThreads ├── 2-2QThreadCreate │ ├── main.cpp │ ├── widget.h │ ├── widget.ui │ └── 2-2QThreadCreate.pro ├── 2-3MoveToThread │ ├── main.cpp │ ├── worker.h │ ├── widget.h │ └── worker.cpp ├── 2-4SubclassQThread │ ├── main.cpp │ ├── workerthread.h │ ├── widget.h │ ├── workerthread.cpp │ └── widget.cpp ├── 2-6-3ThreadPoolAsync │ ├── main.cpp │ ├── progressevent.cpp │ ├── progressevent.h │ ├── worker.h │ ├── widget.h │ ├── worker.cpp │ └── widget.ui ├── 2-5-1AsyncQThreadCreate │ ├── main.cpp │ ├── widget.h │ ├── widget.ui │ ├── widget.cpp │ └── 2-5-1AsyncQThreadCreate.pro ├── 2-5-2AsyncMoveToThread │ ├── main.cpp │ ├── worker.h │ ├── widget.h │ ├── worker.cpp │ ├── widget.cpp │ └── widget.ui ├── 2-5-3AsyncSubclassQThread │ ├── main.cpp │ ├── workerthread.h │ ├── widget.h │ ├── widget.cpp │ ├── workerthread.cpp │ └── widget.ui ├── 2-6-1ThreadPoolRunnable │ ├── main.cpp │ ├── worker.h │ ├── widget.h │ ├── widget.cpp │ ├── worker.cpp │ └── widget.ui ├── 2-6-2ThreadPoolFeedback │ ├── main.cpp │ ├── progessevent.cpp.autosave │ ├── progressevent.cpp │ ├── progressevent.h │ ├── worker.h │ ├── widget.h │ ├── worker.cpp │ └── widget.ui └── 2-7CustomTypeSignals │ ├── main.cpp │ ├── numberedstring.cpp │ ├── worker.h │ ├── numberedstring.h │ ├── widget.h │ └── worker.cpp ├── 5.QtConcurrent ├── 5-4ConcurrentMap │ ├── main.cpp │ ├── widget.h │ ├── widget.ui │ └── 5-4ConcurrentMap.pro ├── 5-5ConcurrentMapped │ ├── main.cpp │ ├── widget.h │ ├── widget.ui │ └── 5-5ConcurrentMapped.pro ├── 5-7CuncurrentFilter │ ├── main.cpp │ ├── widget.h │ └── 5-7CuncurrentFilter.pro ├── 5-10FutureSynchronizer │ ├── main.cpp │ ├── widget.h │ └── 5-10FutureSynchronizer.pro ├── 5-2ConcurrentRunSync │ ├── main.cpp │ ├── widget.h │ ├── widget.cpp │ └── 5-2ConcurrentRunSync.pro ├── 5-3ConcurrentRunAsyc │ ├── main.cpp │ ├── widget.h │ └── 5-3ConcurrentRunAsyc.pro ├── 5-6ConcurrentMapReduced │ └── main.cpp ├── 5-8ConcurrentFiltered │ ├── main.cpp │ ├── widget.h │ └── 5-8ConcurrentFiltered.pro └── 5-9ConcurrentFilterReduce │ ├── main.cpp │ └── widget.h ├── 3.ThreadSynchronization ├── 3-5SynchronizationSemaphone │ ├── main.cpp │ ├── widget.h │ ├── consumer.h │ ├── widget.ui │ ├── consumer.cpp │ ├── producer.cpp │ ├── producer.h │ └── widget.cpp ├── 3-7WaitConditionPauseResume │ ├── main.cpp │ ├── widget.h │ ├── workerthread.h │ └── widget.cpp ├── 3-6SynchronizationWaitConditions │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ ├── widget.ui │ ├── producer.h │ ├── consumer.h │ ├── consumer.cpp │ └── producer.cpp ├── 3-3MutexSharedVariable │ ├── printdevice.cpp │ ├── printdevice.h │ ├── printworker.cpp │ ├── widget.ui │ ├── printworker.h │ └── main.cpp ├── 3-4SynchronizationReadWriteLock │ ├── printdevice.h │ ├── printdevice.cpp │ ├── incrementworker.cpp │ ├── printworker.cpp │ ├── widget.ui │ ├── incrementworker.h │ ├── printworker.h │ └── main.cpp └── 3-2SynchroQMutex │ ├── printworker.h │ ├── main.cpp │ ├── printworker.cpp │ └── 3-2SynchroQMutex.pro └── 4.ThreadSafetyReentrancy ├── 4-5SlotsInQThreadSubclass ├── main.cpp ├── widget.cpp ├── widget.h ├── thread.h ├── widget.ui └── thread.cpp ├── 4-2QueuedConnectins1 ├── main.cpp ├── customdata.cpp ├── consumer.h ├── customdata.h ├── producer.h ├── producer.cpp ├── consumer.cpp ├── widget.h ├── widget.ui └── widget.cpp ├── 4-3QueuedConnections2 ├── main.cpp ├── customdata.cpp ├── thread.cpp ├── consumer.h ├── customdata.h ├── thread.h ├── producer.h ├── consumer.cpp ├── widget.h ├── widget.ui ├── producer.cpp └── widget.cpp └── 4-4QueuedConnections3 ├── main.cpp ├── customdata.cpp ├── consumer.h ├── customdata.h ├── producer.h ├── consumer.cpp ├── widget.h ├── widget.ui ├── producer.cpp └── widget.cpp /README.md: -------------------------------------------------------------------------------- 1 | # ThreadingIPCCode 2 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/2-signals_slots.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | Client \ 5 | Server 6 | -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/3-DbusMessages.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | Client \ 5 | Server 6 | 7 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/4-DBusInterface.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | Client \ 5 | Server 6 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/clientserver.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | Client \ 5 | Server 6 | -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/3-DbusMessages/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/3-DbusMessages/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/4-DBusInterface/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/4-DBusInterface/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/Client: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/Client -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/main.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/Server: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/Server -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/main.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Client.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Client.exe -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Server.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Server.exe -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Client.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/3-DbusMessages/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Client.exe -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Client.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/4-DBusInterface/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Client.exe -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/widget.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/widget.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/3-DbusMessages/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/4-DBusInterface/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o -------------------------------------------------------------------------------- /7.IPC/7-3TcpClient/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /7.IPC/7-3TcpServer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/moc_widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/moc_widget.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/moc_widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/moc_widget.o -------------------------------------------------------------------------------- /6.QProcess/6-1QProcess/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /7.IPC/7-2SharedMemory/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /7.IPC/7-4FileConsumer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /7.IPC/7-4FileProducer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/main.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/main.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/main.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/slavecalculator.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/slavecalculator.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/slavecalculator.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/slavecalculator.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/widget.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/widget.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/widget.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/Client/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/Server/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/calculatoradaptor.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/calculatoradaptor.o -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/Client/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/Server/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/Client/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/Server/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-2QThreadCreate/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-3MoveToThread/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-4ConcurrentMap/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-5ConcurrentMapped/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-7CuncurrentFilter/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/calculatoradaptor.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/calculatoradaptor.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/Client.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/Client.exe -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/Server.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/Server.exe -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Client.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Client.exe -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Server.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/Server.exe -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/calculatorINterface.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/calculatorINterface.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_calculatoradaptor.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_calculatoradaptor.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_slavecalculator.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_slavecalculator.o -------------------------------------------------------------------------------- /2.CreatingThreads/2-4SubclassQThread/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-3ThreadPoolAsync/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-10FutureSynchronizer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-2ConcurrentRunSync/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-3ConcurrentRunAsyc/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-6ConcurrentMapReduced/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-8ConcurrentFiltered/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/calculatorInterface.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/calculatorInterface.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/moc_slavecalculator.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/moc_slavecalculator.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/moc_widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/moc_widget.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/moc_widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/moc_widget.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_widget.o -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_calculatorINterface.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_calculatorINterface.o -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-1AsyncQThreadCreate/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-2AsyncMoveToThread/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-3AsyncSubclassQThread/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-1ThreadPoolRunnable/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-2ThreadPoolFeedback/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-2ThreadPoolFeedback/progessevent.cpp.autosave: -------------------------------------------------------------------------------- 1 | #include "progessevent.h" 2 | 3 | ProgessEvent::ProgessEvent(int progress) : QEvent() 4 | { 5 | 6 | } 7 | 8 | int ProgessEvent::progress() const 9 | { 10 | return m_progress; 11 | } 12 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-9ConcurrentFilterReduce/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/moc_calculatorInterface.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Client/moc_calculatorInterface.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/moc_calculatoradaptor.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/moc_calculatoradaptor.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/Client/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/Server/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/slavecalculator.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/slavecalculator.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/slavecalculator.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/slavecalculator.o -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-5SynchronizationSemaphone/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-7WaitConditionPauseResume/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-5SlotsInQThreadSubclass/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/calculatorInterface.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/calculatorInterface.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/calculatoradaptor.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/calculatoradaptor.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/moc_slavecalculator.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/moc_slavecalculator.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/calculatorInterface.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/calculatorInterface.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/calculatoradaptor.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/calculatoradaptor.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_slavecalculator.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_slavecalculator.o -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-6SynchronizationWaitConditions/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/moc_calculatoradaptor.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Server/debug/moc_calculatoradaptor.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_calculatoradaptor.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_calculatoradaptor.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/moc_calculatorInterface.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/Client/debug/moc_calculatorInterface.o -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_calculatorInterface.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutura/ThreadingIPCCode/HEAD/8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/debug/moc_calculatorInterface.o -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-3ThreadPoolAsync/progressevent.cpp: -------------------------------------------------------------------------------- 1 | #include "progressevent.h" 2 | 3 | ProgessEvent::ProgessEvent(int progress) : QEvent(static_cast(EventId)), 4 | m_progress(progress) 5 | { 6 | 7 | } 8 | 9 | int ProgessEvent::progress() const 10 | { 11 | return m_progress; 12 | } 13 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-2ThreadPoolFeedback/progressevent.cpp: -------------------------------------------------------------------------------- 1 | #include "progressevent.h" 2 | 3 | ProgessEvent::ProgessEvent(int progress) : QEvent(static_cast(EventId)), 4 | m_progress(progress) 5 | { 6 | 7 | } 8 | 9 | int ProgessEvent::progress() const 10 | { 11 | return m_progress; 12 | } 13 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-2QueuedConnectins1/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | #include "customdata.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | qRegisterMetaType(); 9 | Widget w; 10 | w.show(); 11 | 12 | return a.exec(); 13 | } 14 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | #include "customdata.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | qRegisterMetaType(); 9 | Widget w; 10 | w.show(); 11 | 12 | return a.exec(); 13 | } 14 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-4QueuedConnections3/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | #include "customdata.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | qRegisterMetaType(); 9 | Widget w; 10 | w.show(); 11 | 12 | return a.exec(); 13 | } 14 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-7CustomTypeSignals/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | #include "numberedstring.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | 9 | qRegisterMetaType("NumberedString"); 10 | Widget w; 11 | w.show(); 12 | 13 | return a.exec(); 14 | } 15 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-1ThreadPoolRunnable/worker.h: -------------------------------------------------------------------------------- 1 | #ifndef WORKER_H 2 | #define WORKER_H 3 | 4 | #include 5 | 6 | class Worker : public QRunnable 7 | { 8 | 9 | public: 10 | explicit Worker(); 11 | ~Worker() override; 12 | 13 | 14 | // QRunnable interface 15 | public: 16 | void run() override; 17 | }; 18 | 19 | #endif // WORKER_H 20 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-2AsyncMoveToThread/worker.h: -------------------------------------------------------------------------------- 1 | #ifndef WORKER_H 2 | #define WORKER_H 3 | 4 | #include 5 | 6 | class Worker : public QObject 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit Worker(QObject *parent = nullptr); 11 | ~Worker(); 12 | 13 | signals: 14 | 15 | public slots: 16 | void doWork(); 17 | 18 | }; 19 | 20 | #endif // WORKER_H 21 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-3MutexSharedVariable/printdevice.cpp: -------------------------------------------------------------------------------- 1 | #include "printdevice.h" 2 | #include 3 | #include 4 | 5 | PrintDevice::PrintDevice() 6 | { 7 | m_count = 0; 8 | } 9 | 10 | void PrintDevice::print(const QString &text) 11 | { 12 | QMutexLocker locker(&m_mutex); 13 | qDebug() << text << "Called , count : " << m_count++ ; 14 | } 15 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-2QueuedConnectins1/customdata.cpp: -------------------------------------------------------------------------------- 1 | #include "customdata.h" 2 | 3 | CustomData::CustomData() : 4 | m_integer(-1),m_pointer(nullptr),m_string() 5 | { 6 | 7 | } 8 | 9 | CustomData::CustomData(int integerArg, int *pointerArg, const QString &stringArg) : 10 | m_integer(integerArg), m_pointer(pointerArg),m_string(stringArg) 11 | { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/customdata.cpp: -------------------------------------------------------------------------------- 1 | #include "customdata.h" 2 | 3 | CustomData::CustomData() : 4 | m_integer(-1),m_pointer(nullptr),m_string() 5 | { 6 | 7 | } 8 | 9 | CustomData::CustomData(int integerArg, int *pointerArg, const QString &stringArg) : 10 | m_integer(integerArg), m_pointer(pointerArg),m_string(stringArg) 11 | { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-4QueuedConnections3/customdata.cpp: -------------------------------------------------------------------------------- 1 | #include "customdata.h" 2 | 3 | CustomData::CustomData() : 4 | m_integer(-1),m_pointer(nullptr),m_string() 5 | { 6 | 7 | } 8 | 9 | CustomData::CustomData(int integerArg, int *pointerArg, const QString &stringArg) : 10 | m_integer(integerArg), m_pointer(pointerArg),m_string(stringArg) 11 | { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-3MutexSharedVariable/printdevice.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINTDEVICE_H 2 | #define PRINTDEVICE_H 3 | 4 | #include 5 | #include 6 | 7 | class PrintDevice 8 | { 9 | public: 10 | PrintDevice(); 11 | 12 | void print(const QString & text); 13 | 14 | private: 15 | int m_count; 16 | QMutex m_mutex; 17 | }; 18 | 19 | #endif // PRINTDEVICE_H 20 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-2ThreadPoolFeedback/progressevent.h: -------------------------------------------------------------------------------- 1 | #ifndef PROGESSEVENT_H 2 | #define PROGESSEVENT_H 3 | 4 | #include 5 | 6 | class ProgessEvent : public QEvent 7 | { 8 | public: 9 | enum {EventId = QEvent::User +1}; 10 | ProgessEvent( int progress = 0); 11 | 12 | 13 | 14 | int progress() const; 15 | 16 | private: 17 | int m_progress; 18 | }; 19 | 20 | #endif // PROGESSEVENT_H 21 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-3ThreadPoolAsync/progressevent.h: -------------------------------------------------------------------------------- 1 | #ifndef PROGESSEVENT_H 2 | #define PROGESSEVENT_H 3 | 4 | #include 5 | 6 | class ProgessEvent : public QEvent 7 | { 8 | public: 9 | enum {EventId = QEvent::User +1}; 10 | ProgessEvent( int progress = 0); 11 | 12 | 13 | 14 | int progress() const; 15 | 16 | private: 17 | int m_progress; 18 | }; 19 | 20 | #endif // PROGESSEVENT_H 21 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-3MoveToThread/worker.h: -------------------------------------------------------------------------------- 1 | #ifndef WORKER_H 2 | #define WORKER_H 3 | 4 | #include 5 | 6 | class Worker : public QObject 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit Worker(QObject *parent = nullptr); 11 | ~Worker(); 12 | 13 | signals: 14 | void currentCount(int value); 15 | void countDone(); 16 | public slots: 17 | void doCounting(); 18 | }; 19 | 20 | #endif // WORKER_H 21 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/thread.cpp: -------------------------------------------------------------------------------- 1 | #include "thread.h" 2 | #include "consumer.h" 3 | 4 | Thread::Thread(Producer * producer , QObject *parent) : QThread(parent), 5 | m_producer(producer) 6 | { 7 | 8 | } 9 | 10 | void Thread::run() 11 | { 12 | Consumer consumer; 13 | connect(m_producer,&Producer::data,&consumer,&Consumer::data); 14 | 15 | //Start our own event loop 16 | exec(); 17 | } 18 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-7CustomTypeSignals/numberedstring.cpp: -------------------------------------------------------------------------------- 1 | #include "numberedstring.h" 2 | 3 | NumberedString::NumberedString() 4 | { 5 | 6 | } 7 | 8 | NumberedString::NumberedString(int number, QString string) : 9 | m_number(number), m_string(string) 10 | { 11 | 12 | } 13 | 14 | int NumberedString::number() const 15 | { 16 | return m_number; 17 | } 18 | 19 | QString NumberedString::string() const 20 | { 21 | return m_string; 22 | } 23 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-3ThreadPoolAsync/worker.h: -------------------------------------------------------------------------------- 1 | #ifndef WORKER_H 2 | #define WORKER_H 3 | 4 | #include 5 | #include 6 | 7 | class Worker : public QRunnable 8 | { 9 | 10 | public: 11 | explicit Worker(QObject * receiver); 12 | ~Worker() override; 13 | 14 | 15 | // QRunnable interface 16 | public: 17 | void run() override; 18 | 19 | private: 20 | QObject * m_receiver; 21 | }; 22 | 23 | #endif // WORKER_H 24 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-3MutexSharedVariable/printworker.cpp: -------------------------------------------------------------------------------- 1 | #include "printworker.h" 2 | 3 | PrintWorker::PrintWorker(QString name, bool * stop, PrintDevice * printDevice,QObject *parent) 4 | : QThread(parent), 5 | m_name(name), m_stop(stop),m_print_device(printDevice) 6 | { 7 | 8 | } 9 | void PrintWorker:: run() { 10 | while(!*m_stop){ 11 | 12 | m_print_device->print(m_name); 13 | sleep(1); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-2QueuedConnectins1/consumer.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSUMER_H 2 | #define CONSUMER_H 3 | 4 | #include 5 | #include 6 | 7 | class Consumer : public QObject 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit Consumer(QObject *parent = nullptr); 12 | 13 | signals: 14 | 15 | public slots: 16 | void data(const CustomData &cd); 17 | private: 18 | int m_counter; 19 | }; 20 | 21 | #endif // CONSUMER_H 22 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/consumer.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSUMER_H 2 | #define CONSUMER_H 3 | 4 | #include 5 | #include 6 | 7 | class Consumer : public QObject 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit Consumer(QObject *parent = nullptr); 12 | 13 | signals: 14 | 15 | public slots: 16 | void data(const CustomData &cd); 17 | private: 18 | int m_counter; 19 | }; 20 | 21 | #endif // CONSUMER_H 22 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-4QueuedConnections3/consumer.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSUMER_H 2 | #define CONSUMER_H 3 | 4 | #include 5 | #include 6 | 7 | class Consumer : public QObject 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit Consumer(QObject *parent = nullptr); 12 | 13 | signals: 14 | 15 | public slots: 16 | void data(const CustomData &cd); 17 | private: 18 | int m_counter; 19 | }; 20 | 21 | #endif // CONSUMER_H 22 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-2ThreadPoolFeedback/worker.h: -------------------------------------------------------------------------------- 1 | #ifndef WORKER_H 2 | #define WORKER_H 3 | 4 | #include 5 | #include 6 | 7 | class Worker : public QRunnable 8 | { 9 | 10 | public: 11 | explicit Worker(QObject * receiver); 12 | ~Worker() override; 13 | 14 | 15 | // QRunnable interface 16 | public: 17 | void run() override; 18 | 19 | private: 20 | QObject * m_receiver; 21 | }; 22 | 23 | #endif // WORKER_H 24 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-4SynchronizationReadWriteLock/printdevice.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINTDEVICE_H 2 | #define PRINTDEVICE_H 3 | 4 | #include 5 | #include 6 | 7 | class PrintDevice 8 | { 9 | public: 10 | PrintDevice(); 11 | 12 | void print(const QString & text); 13 | 14 | void increment(); 15 | 16 | private: 17 | int m_count; 18 | QReadWriteLock m_read_write_lock; 19 | }; 20 | 21 | #endif // PRINTDEVICE_H 22 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-2QueuedConnectins1/customdata.h: -------------------------------------------------------------------------------- 1 | #ifndef CUSTOMDATA_H 2 | #define CUSTOMDATA_H 3 | 4 | #include 5 | #include 6 | 7 | class CustomData 8 | { 9 | public: 10 | CustomData(); 11 | CustomData(int integerArg, int* pointerArg, const QString& stringArg); 12 | 13 | 14 | int m_integer; 15 | int *m_pointer; 16 | QString m_string; 17 | }; 18 | Q_DECLARE_METATYPE(CustomData) 19 | 20 | #endif // CUSTOMDATA_H 21 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/customdata.h: -------------------------------------------------------------------------------- 1 | #ifndef CUSTOMDATA_H 2 | #define CUSTOMDATA_H 3 | 4 | #include 5 | #include 6 | 7 | class CustomData 8 | { 9 | public: 10 | CustomData(); 11 | CustomData(int integerArg, int* pointerArg, const QString& stringArg); 12 | 13 | 14 | int m_integer; 15 | int *m_pointer; 16 | QString m_string; 17 | }; 18 | Q_DECLARE_METATYPE(CustomData) 19 | 20 | #endif // CUSTOMDATA_H 21 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-4QueuedConnections3/customdata.h: -------------------------------------------------------------------------------- 1 | #ifndef CUSTOMDATA_H 2 | #define CUSTOMDATA_H 3 | 4 | #include 5 | #include 6 | 7 | class CustomData 8 | { 9 | public: 10 | CustomData(); 11 | CustomData(int integerArg, int* pointerArg, const QString& stringArg); 12 | 13 | 14 | int m_integer; 15 | int *m_pointer; 16 | QString m_string; 17 | }; 18 | Q_DECLARE_METATYPE(CustomData) 19 | 20 | #endif // CUSTOMDATA_H 21 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-5SlotsInQThreadSubclass/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | 5 | Widget::Widget(QWidget *parent) : 6 | QWidget(parent), 7 | ui(new Ui::Widget) 8 | { 9 | ui->setupUi(this); 10 | 11 | qDebug() << "GUI thread : " << QThread::currentThread(); 12 | 13 | thread = new Thread(this); 14 | thread->start(); 15 | } 16 | 17 | Widget::~Widget() 18 | { 19 | delete ui; 20 | } 21 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-5SlotsInQThreadSubclass/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "thread.h" 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private: 20 | Ui::Widget *ui; 21 | Thread * thread; 22 | 23 | }; 24 | 25 | #endif // WIDGET_H 26 | -------------------------------------------------------------------------------- /7.IPC/7-4FileProducer/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Widget; 8 | } 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private slots: 19 | void on_lineEdit_textChanged(const QString &text); 20 | 21 | private: 22 | Ui::Widget *ui; 23 | }; 24 | 25 | #endif // WIDGET_H 26 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-3AsyncSubclassQThread/workerthread.h: -------------------------------------------------------------------------------- 1 | #ifndef WORKERTHREAD_H 2 | #define WORKERTHREAD_H 3 | 4 | #include 5 | 6 | class WorkerThread : public QThread 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit WorkerThread(QObject *parent = nullptr); 11 | ~ WorkerThread() override; 12 | 13 | signals: 14 | 15 | public slots: 16 | 17 | // QThread interface 18 | protected: 19 | void run() override; 20 | }; 21 | 22 | #endif // WORKERTHREAD_H 23 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-2QueuedConnectins1/producer.h: -------------------------------------------------------------------------------- 1 | #ifndef PRODUCER_H 2 | #define PRODUCER_H 3 | 4 | #include 5 | #include "customdata.h" 6 | 7 | class Producer : public QPushButton 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit Producer(QWidget *parent = nullptr); 12 | 13 | signals: 14 | void data(const CustomData &); 15 | 16 | public slots: 17 | void sendData(); 18 | 19 | private: 20 | int m_integer; 21 | }; 22 | 23 | #endif // PRODUCER_H 24 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/Server/slavecalculator.cpp: -------------------------------------------------------------------------------- 1 | #include "slavecalculator.h" 2 | 3 | SlaveCalculator::SlaveCalculator(QObject *parent) : QObject(parent) 4 | { 5 | 6 | } 7 | 8 | double SlaveCalculator::multiply(double factor1, double factor2) 9 | { 10 | double product = factor1 * factor2; 11 | return product; 12 | } 13 | 14 | double SlaveCalculator::divide(double divident, double divisor) 15 | { 16 | double quotient = divident / divisor; 17 | return quotient; 18 | } 19 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-4SynchronizationReadWriteLock/printdevice.cpp: -------------------------------------------------------------------------------- 1 | #include "printdevice.h" 2 | #include 3 | 4 | PrintDevice::PrintDevice() 5 | { 6 | m_count = 0; 7 | } 8 | 9 | 10 | void PrintDevice::print(const QString & text){ 11 | 12 | QReadLocker readLocker(&m_read_write_lock); 13 | qDebug() << text << "Called , count : " << m_count ; 14 | 15 | } 16 | 17 | void PrintDevice::increment(){ 18 | QWriteLocker writeLocker(&m_read_write_lock); 19 | m_count++; 20 | } 21 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/thread.h: -------------------------------------------------------------------------------- 1 | #ifndef THREAD_H 2 | #define THREAD_H 3 | 4 | #include 5 | #include "producer.h" 6 | 7 | class Thread : public QThread 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit Thread(Producer * producer,QObject *parent = nullptr); 12 | 13 | signals: 14 | 15 | public slots: 16 | private: 17 | Producer * m_producer; 18 | 19 | // QThread interface 20 | protected: 21 | void run() override; 22 | }; 23 | 24 | #endif // THREAD_H 25 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-4SubclassQThread/workerthread.h: -------------------------------------------------------------------------------- 1 | #ifndef WORKERTHREAD_H 2 | #define WORKERTHREAD_H 3 | 4 | #include 5 | 6 | class WorkerThread : public QThread 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit WorkerThread(QObject *parent = nullptr); 11 | ~WorkerThread() override; 12 | 13 | signals: 14 | void currentCount(int value); 15 | 16 | public slots: 17 | 18 | // QThread interface 19 | protected: 20 | void run() override; 21 | }; 22 | 23 | #endif // WORKERTHREAD_H 24 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-1ThreadPoolRunnable/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Widget; 8 | } 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private slots: 19 | void on_startButton_clicked(); 20 | 21 | void on_infoButton_clicked(); 22 | 23 | private: 24 | Ui::Widget *ui; 25 | }; 26 | 27 | #endif // WIDGET_H 28 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-7CustomTypeSignals/worker.h: -------------------------------------------------------------------------------- 1 | #ifndef WORKER_H 2 | #define WORKER_H 3 | 4 | #include 5 | #include "numberedstring.h" 6 | 7 | class Worker : public QObject 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit Worker(QObject *parent = nullptr); 12 | ~Worker(); 13 | 14 | signals: 15 | void currentCount(int value); 16 | void currentNumberString(NumberedString ns); 17 | void countDone(); 18 | public slots: 19 | void doCounting(); 20 | }; 21 | 22 | #endif // WORKER_H 23 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-4SynchronizationReadWriteLock/incrementworker.cpp: -------------------------------------------------------------------------------- 1 | #include "incrementworker.h" 2 | 3 | IncrementWorker::IncrementWorker(bool * stop,PrintDevice * printDevice, 4 | QObject *parent) : QThread(parent), 5 | m_print_device(printDevice), 6 | m_stop(stop) 7 | { 8 | 9 | } 10 | 11 | void IncrementWorker::run() 12 | { 13 | while (!(*m_stop)) { 14 | msleep(1500); 15 | m_print_device->increment(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-1AsyncQThreadCreate/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_startButton_clicked(); 21 | 22 | private: 23 | Ui::Widget *ui; 24 | QThread * thread; 25 | }; 26 | 27 | #endif // WIDGET_H 28 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-7CustomTypeSignals/numberedstring.h: -------------------------------------------------------------------------------- 1 | #ifndef NUMBEREDSTRING_H 2 | #define NUMBEREDSTRING_H 3 | 4 | #include 5 | #include 6 | 7 | class NumberedString 8 | { 9 | public: 10 | NumberedString(); 11 | NumberedString(int number , QString string); 12 | 13 | int number() const; 14 | 15 | QString string() const; 16 | 17 | private: 18 | int m_number; 19 | QString m_string; 20 | }; 21 | Q_DECLARE_METATYPE(NumberedString) 22 | 23 | #endif // NUMBEREDSTRING_H 24 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-4SynchronizationReadWriteLock/printworker.cpp: -------------------------------------------------------------------------------- 1 | #include "printworker.h" 2 | 3 | PrintWorker::PrintWorker(const QString & name,bool * stop,PrintDevice * printDevice, 4 | QObject *parent) : QThread(parent), 5 | m_name(name), 6 | m_stop(stop), 7 | m_print_device(printDevice) 8 | 9 | { 10 | 11 | } 12 | 13 | void PrintWorker::run(){ 14 | while (!(*m_stop)) { 15 | 16 | m_print_device->print(m_name); 17 | sleep(1); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-5SlotsInQThreadSubclass/thread.h: -------------------------------------------------------------------------------- 1 | #ifndef THREAD_H 2 | #define THREAD_H 3 | 4 | #include 5 | #include 6 | 7 | class Thread : public QThread 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit Thread(QObject *parent = nullptr); 12 | 13 | signals: 14 | 15 | public slots: 16 | void increment(); 17 | 18 | // QThread interface 19 | protected: 20 | void run() override; 21 | 22 | private: 23 | QTimer * m_timer; 24 | int m_count; 25 | }; 26 | 27 | #endif // THREAD_H 28 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-2QueuedConnectins1/producer.cpp: -------------------------------------------------------------------------------- 1 | #include "producer.h" 2 | #include 3 | #include 4 | 5 | Producer::Producer(QWidget *parent) : QPushButton(parent) 6 | { 7 | connect(this,&Producer::clicked,this,&Producer::sendData); 8 | m_integer = 10; 9 | setText("Produce"); 10 | } 11 | 12 | void Producer::sendData() 13 | { 14 | qDebug() << "Producer producing data , thread :" << QThread::currentThread(); 15 | CustomData cd(10, &m_integer, "Produced data"); 16 | emit data(cd); 17 | } 18 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-2QThreadCreate/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | void counting(); 20 | 21 | private slots: 22 | void on_startButton_clicked(); 23 | 24 | private: 25 | Ui::Widget *ui; 26 | QThread * thread; 27 | }; 28 | 29 | #endif // WIDGET_H 30 | -------------------------------------------------------------------------------- /7.IPC/7-4FileConsumer/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots : 20 | void reloadFile(); 21 | 22 | private: 23 | void createFileIfNotExist(); 24 | Ui::Widget *ui; 25 | QFileSystemWatcher *m_watcher; 26 | }; 27 | 28 | #endif // WIDGET_H 29 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/Server/slavecalculator.h: -------------------------------------------------------------------------------- 1 | #ifndef SLAVECALCULATOR_H 2 | #define SLAVECALCULATOR_H 3 | 4 | #include 5 | 6 | class SlaveCalculator : public QObject 7 | { 8 | Q_OBJECT 9 | Q_CLASSINFO("D-Bus Interface", "com.blikoon.CalculatorInterface") 10 | public: 11 | explicit SlaveCalculator(QObject *parent = nullptr); 12 | 13 | public slots: 14 | double multiply(double factor1, double factor2); 15 | double divide(double divident, double divisor); 16 | }; 17 | 18 | #endif // SLAVECALCULATOR_H 19 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-3MutexSharedVariable/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | Widget 3 | 4 | 5 | 6 | 0 7 | 0 8 | 400 9 | 300 10 | 11 | 12 | 13 | Widget 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-5SlotsInQThreadSubclass/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | Widget 3 | 4 | 5 | 6 | 0 7 | 0 8 | 400 9 | 300 10 | 11 | 12 | 13 | Widget 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/Server/slavecalculator.cpp: -------------------------------------------------------------------------------- 1 | #include "slavecalculator.h" 2 | 3 | SlaveCalculator::SlaveCalculator(QObject *parent) : QObject(parent) 4 | { 5 | 6 | } 7 | 8 | double SlaveCalculator::multiply(double factor1, double factor2) 9 | { 10 | double product = factor1 * factor2; 11 | emit productResult(product); 12 | return product; 13 | } 14 | 15 | double SlaveCalculator::divide(double divident, double divisor) 16 | { 17 | double quotient = divident / divisor; 18 | emit divisionResult(quotient); 19 | return quotient; 20 | } 21 | -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/Server/slavecalculator.cpp: -------------------------------------------------------------------------------- 1 | #include "slavecalculator.h" 2 | 3 | SlaveCalculator::SlaveCalculator(QObject *parent) : QObject(parent) 4 | { 5 | 6 | } 7 | 8 | double SlaveCalculator::multiply(double factor1, double factor2) 9 | { 10 | double product = factor1 * factor2; 11 | emit productResult(product); 12 | return product; 13 | } 14 | 15 | double SlaveCalculator::divide(double divident, double divisor) 16 | { 17 | double quotient = divident / divisor; 18 | emit divisionResult(quotient); 19 | return quotient; 20 | } 21 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/Server/slavecalculator.cpp: -------------------------------------------------------------------------------- 1 | #include "slavecalculator.h" 2 | 3 | SlaveCalculator::SlaveCalculator(QObject *parent) : QObject(parent) 4 | { 5 | 6 | } 7 | 8 | double SlaveCalculator::multiply(double factor1, double factor2) 9 | { 10 | double product = factor1 * factor2; 11 | emit productResult(product); 12 | return product; 13 | } 14 | 15 | double SlaveCalculator::divide(double divident, double divisor) 16 | { 17 | double quotient = divident / divisor; 18 | emit divisionResult(quotient); 19 | return quotient; 20 | } 21 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-4SynchronizationReadWriteLock/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | Widget 3 | 4 | 5 | 6 | 0 7 | 0 8 | 400 9 | 300 10 | 11 | 12 | 13 | Widget 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/producer.h: -------------------------------------------------------------------------------- 1 | #ifndef PRODUCER_H 2 | #define PRODUCER_H 3 | 4 | #include 5 | #include 6 | #include "customdata.h" 7 | 8 | class Producer : public QPushButton 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit Producer(QWidget *parent = nullptr); 13 | 14 | signals: 15 | void data(const CustomData &); 16 | 17 | public slots: 18 | void sendData(); 19 | void startProduction(); 20 | 21 | private: 22 | int m_integer; 23 | QTimer * m_timer; 24 | }; 25 | 26 | #endif // PRODUCER_H 27 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-4QueuedConnections3/producer.h: -------------------------------------------------------------------------------- 1 | #ifndef PRODUCER_H 2 | #define PRODUCER_H 3 | 4 | #include 5 | #include 6 | #include "customdata.h" 7 | 8 | class Producer : public QPushButton 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit Producer(QWidget *parent = nullptr); 13 | 14 | signals: 15 | void data(const CustomData &); 16 | 17 | public slots: 18 | void sendData(); 19 | void startProduction(); 20 | 21 | private: 22 | int m_integer; 23 | QTimer * m_timer; 24 | }; 25 | 26 | #endif // PRODUCER_H 27 | -------------------------------------------------------------------------------- /7.IPC/7-3TcpServer/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Ui { 9 | class Widget; 10 | } 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | protected slots : 21 | void gotConnection(); 22 | void readData(); 23 | 24 | private: 25 | Ui::Widget *ui; 26 | QTcpServer m_server; 27 | QTcpSocket *m_socket; 28 | }; 29 | 30 | #endif // WIDGET_H 31 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-2AsyncMoveToThread/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_startButton_clicked(); 21 | 22 | void on_stopButton_clicked(); 23 | 24 | void on_infoButton_clicked(); 25 | 26 | private: 27 | Ui::Widget *ui; 28 | QThread * thread; 29 | }; 30 | 31 | #endif // WIDGET_H 32 | -------------------------------------------------------------------------------- /7.IPC/7-2SharedMemory/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_loadImageButton_clicked(); 21 | 22 | void on_loadShareMemoryButton_clicked(); 23 | 24 | void detach(); 25 | 26 | private: 27 | Ui::Widget *ui; 28 | QSharedMemory sharedMemory; 29 | 30 | }; 31 | 32 | #endif // WIDGET_H 33 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-4SubclassQThread/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_startButton_clicked(); 21 | 22 | void on_infoButton_clicked(); 23 | 24 | void currentCount(int value); 25 | 26 | private: 27 | Ui::Widget *ui; 28 | WorkerThread * workerThread; 29 | }; 30 | 31 | #endif // WIDGET_H 32 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-3MutexSharedVariable/printworker.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINTWORKER_H 2 | #define PRINTWORKER_H 3 | 4 | #include 5 | #include "printdevice.h" 6 | 7 | class PrintWorker : public QThread 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit PrintWorker(QString name, bool * stop, PrintDevice * worker,QObject *parent = nullptr); 12 | 13 | signals: 14 | 15 | public slots: 16 | private: 17 | QString m_name; 18 | bool * m_stop; 19 | PrintDevice * m_print_device; 20 | 21 | // QThread interface 22 | protected: 23 | void run() override; 24 | }; 25 | 26 | #endif // PRINTWORKER_H 27 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-3AsyncSubclassQThread/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "workerthread.h" 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_startButton_clicked(); 21 | 22 | void on_stopButton_clicked(); 23 | 24 | void on_infoButton_clicked(); 25 | 26 | private: 27 | Ui::Widget *ui; 28 | WorkerThread * thread; 29 | }; 30 | 31 | #endif // WIDGET_H 32 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-4SynchronizationReadWriteLock/incrementworker.h: -------------------------------------------------------------------------------- 1 | #ifndef INCREMENTWORKER_H 2 | #define INCREMENTWORKER_H 3 | 4 | #include 5 | #include "printdevice.h" 6 | 7 | class IncrementWorker : public QThread 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit IncrementWorker(bool * stop,PrintDevice * printDevice,QObject *parent = nullptr); 12 | 13 | signals: 14 | 15 | public slots: 16 | 17 | private: 18 | PrintDevice * m_print_device; 19 | bool * m_stop ; 20 | 21 | // QThread interface 22 | protected: 23 | void run() override; 24 | }; 25 | 26 | #endif // INCREMENTWORKER_H 27 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-2QueuedConnectins1/consumer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "consumer.h" 4 | 5 | Consumer::Consumer(QObject *parent) : QObject(parent) 6 | { 7 | m_counter = 0; 8 | } 9 | 10 | void Consumer::data(const CustomData &cd) 11 | { 12 | qDebug() << "Consumer message : " << cd.m_integer << *cd.m_pointer << cd.m_string 13 | << " thread : " << QThread::currentThread(); 14 | 15 | //Kill the thread 16 | if( ++m_counter > 10){ 17 | qDebug() << "Consumer , threa about to be killed"; 18 | thread()->quit(); 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/consumer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "consumer.h" 4 | 5 | Consumer::Consumer(QObject *parent) : QObject(parent) 6 | { 7 | m_counter = 0; 8 | } 9 | 10 | void Consumer::data(const CustomData &cd) 11 | { 12 | qDebug() << "Consumer message : " << cd.m_integer << *cd.m_pointer << cd.m_string 13 | << " thread : " << QThread::currentThread(); 14 | 15 | //Kill the thread 16 | if( ++m_counter > 10){ 17 | qDebug() << "Consumer , threa about to be killed"; 18 | thread()->quit(); 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-4QueuedConnections3/consumer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "consumer.h" 4 | 5 | Consumer::Consumer(QObject *parent) : QObject(parent) 6 | { 7 | m_counter = 0; 8 | } 9 | 10 | void Consumer::data(const CustomData &cd) 11 | { 12 | qDebug() << "Consumer message : " << cd.m_integer << *cd.m_pointer << cd.m_string 13 | << " thread : " << QThread::currentThread(); 14 | 15 | //Kill the thread 16 | if( ++m_counter > 10){ 17 | qDebug() << "Consumer , threa about to be killed"; 18 | thread()->quit(); 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/Server/slavecalculator.h: -------------------------------------------------------------------------------- 1 | #ifndef SLAVECALCULATOR_H 2 | #define SLAVECALCULATOR_H 3 | 4 | #include 5 | 6 | class SlaveCalculator : public QObject 7 | { 8 | Q_OBJECT 9 | Q_CLASSINFO("D-Bus Interface", "com.blikoon.CalculatorInterface") 10 | public: 11 | explicit SlaveCalculator(QObject *parent = nullptr); 12 | 13 | public slots: 14 | double multiply(double factor1, double factor2); 15 | double divide(double divident, double divisor); 16 | 17 | signals: 18 | void productResult(double product); 19 | void divisionResult(double quotient); 20 | }; 21 | 22 | #endif // SLAVECALCULATOR_H 23 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-4SynchronizationReadWriteLock/printworker.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINTWORKER_H 2 | #define PRINTWORKER_H 3 | 4 | #include 5 | #include "printdevice.h" 6 | 7 | class PrintWorker : public QThread 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit PrintWorker(const QString & name,bool * stop,PrintDevice * printDevice,QObject *parent = nullptr); 12 | 13 | signals: 14 | 15 | public slots: 16 | private: 17 | QString m_name; 18 | bool * m_stop ; 19 | PrintDevice * m_print_device; 20 | 21 | 22 | // QThread interface 23 | protected: 24 | void run() override; 25 | }; 26 | 27 | #endif // PRINTWORKER_H 28 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/Server/slavecalculator.h: -------------------------------------------------------------------------------- 1 | #ifndef SLAVECALCULATOR_H 2 | #define SLAVECALCULATOR_H 3 | 4 | #include 5 | 6 | class SlaveCalculator : public QObject 7 | { 8 | Q_OBJECT 9 | Q_CLASSINFO("D-Bus Interface", "com.blikoon.CalculatorInterface") 10 | public: 11 | explicit SlaveCalculator(QObject *parent = nullptr); 12 | 13 | public slots: 14 | double multiply(double factor1, double factor2); 15 | double divide(double divident, double divisor); 16 | 17 | signals: 18 | void productResult(double product); 19 | void divisionResult(double quotient); 20 | }; 21 | 22 | #endif // SLAVECALCULATOR_H 23 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/Server/slavecalculator.h: -------------------------------------------------------------------------------- 1 | #ifndef SLAVECALCULATOR_H 2 | #define SLAVECALCULATOR_H 3 | 4 | #include 5 | 6 | class SlaveCalculator : public QObject 7 | { 8 | Q_OBJECT 9 | Q_CLASSINFO("D-Bus Interface", "com.blikoon.CalculatorInterface") 10 | public: 11 | explicit SlaveCalculator(QObject *parent = nullptr); 12 | 13 | public slots: 14 | double multiply(double factor1, double factor2); 15 | double divide(double divident, double divisor); 16 | 17 | signals: 18 | void productResult(double product); 19 | void divisionResult(double quotient); 20 | }; 21 | 22 | #endif // SLAVECALCULATOR_H 23 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-2SynchroQMutex/printworker.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINTWORKER_H 2 | #define PRINTWORKER_H 3 | 4 | #include 5 | #include 6 | 7 | class PrintWorker : public QThread 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit PrintWorker(QString name, bool * stop, QMutex * mutex, 12 | QObject *parent = nullptr); 13 | ~PrintWorker() override; 14 | 15 | signals: 16 | 17 | public slots: 18 | 19 | // QThread interface 20 | protected: 21 | void run() override; 22 | private: 23 | QString m_name; 24 | bool * m_stop; 25 | QMutex * m_mutex; 26 | }; 27 | 28 | #endif // PRINTWORKER_H 29 | -------------------------------------------------------------------------------- /7.IPC/7-3TcpClient/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots : 20 | void socketReady(); 21 | void stateChanged(QAbstractSocket::SocketState socketState); 22 | 23 | void on_lineEdit_textChanged(const QString &newText); 24 | 25 | private: 26 | Ui::Widget *ui; 27 | QTcpSocket *m_socket; 28 | bool m_socketReady; 29 | }; 30 | 31 | #endif // WIDGET_H 32 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-2AsyncMoveToThread/worker.cpp: -------------------------------------------------------------------------------- 1 | #include "worker.h" 2 | #include 3 | #include 4 | #include 5 | 6 | Worker::Worker(QObject *parent) : QObject(parent) 7 | { 8 | 9 | } 10 | 11 | Worker:: ~Worker(){ 12 | qDebug() << "Worker destructor running in thread : " << QThread::currentThread(); 13 | } 14 | 15 | 16 | 17 | 18 | void Worker::doWork() 19 | { 20 | 21 | QTimer * timer = new QTimer(); 22 | connect(timer,&QTimer::timeout,[](){ 23 | qDebug() << "Time out . Running in thread : " << QThread::currentThread(); 24 | }); 25 | timer->setInterval(1000); 26 | timer->start(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-1ThreadPoolRunnable/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include "worker.h" 4 | #include 5 | #include 6 | 7 | Widget::Widget(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::Widget) 10 | { 11 | ui->setupUi(this); 12 | qDebug() << "Ui thread :" << QThread::currentThread(); 13 | } 14 | 15 | Widget::~Widget() 16 | { 17 | delete ui; 18 | } 19 | 20 | void Widget::on_startButton_clicked() 21 | { 22 | Worker * worker = new Worker(); 23 | 24 | QThreadPool::globalInstance()->start(worker); 25 | } 26 | 27 | void Widget::on_infoButton_clicked() 28 | { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-3ThreadPoolAsync/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Widget; 8 | } 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Widget(QWidget *parent = nullptr); 16 | ~Widget() override; 17 | 18 | public slots : 19 | void gotUpdate(int value); 20 | 21 | private slots: 22 | void on_startButton_clicked(); 23 | 24 | void on_infoButton_clicked(); 25 | 26 | private: 27 | Ui::Widget *ui; 28 | 29 | // QObject interface 30 | public: 31 | bool event(QEvent *event) override; 32 | }; 33 | 34 | #endif // WIDGET_H 35 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-3MoveToThread/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_startButton_clicked(); 21 | 22 | void on_infoButton_clicked(); 23 | 24 | void countDone(); 25 | 26 | void currentCount(int value); 27 | 28 | void threadFinished(); 29 | 30 | private: 31 | Ui::Widget *ui; 32 | QThread * workerThread; 33 | }; 34 | 35 | #endif // WIDGET_H 36 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-2ThreadPoolFeedback/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Widget; 8 | } 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Widget(QWidget *parent = nullptr); 16 | ~Widget() override; 17 | 18 | public slots : 19 | void gotUpdate(int value); 20 | 21 | private slots: 22 | void on_startButton_clicked(); 23 | 24 | void on_infoButton_clicked(); 25 | 26 | private: 27 | Ui::Widget *ui; 28 | 29 | // QObject interface 30 | public: 31 | bool event(QEvent *event) override; 32 | }; 33 | 34 | #endif // WIDGET_H 35 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-2QueuedConnectins1/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "producer.h" 6 | #include "consumer.h" 7 | #include 8 | 9 | namespace Ui { 10 | class Widget; 11 | } 12 | 13 | class Widget : public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit Widget(QWidget *parent = nullptr); 19 | ~Widget(); 20 | 21 | private: 22 | Ui::Widget *ui; 23 | Producer * producer; 24 | Consumer * consumer; 25 | QThread * thread; 26 | 27 | // QWidget interface 28 | protected: 29 | void closeEvent(QCloseEvent *event) override; 30 | }; 31 | 32 | #endif // WIDGET_H 33 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-7WaitConditionPauseResume/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "workerthread.h" 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_startButton_clicked(); 21 | 22 | void on_pauseButton_clicked(); 23 | 24 | void on_resumeButton_clicked(); 25 | 26 | void currentCount(int value); 27 | 28 | private: 29 | Ui::Widget *ui; 30 | WorkerThread * workerThread; 31 | }; 32 | 33 | #endif // WIDGET_H 34 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "producer.h" 6 | #include "consumer.h" 7 | #include "thread.h" 8 | 9 | namespace Ui { 10 | class Widget; 11 | } 12 | 13 | class Widget : public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit Widget(QWidget *parent = nullptr); 19 | ~Widget() override; 20 | 21 | private: 22 | Ui::Widget *ui; 23 | Producer * producer; 24 | Consumer * consumer; 25 | Thread * thread; 26 | 27 | // QWidget interface 28 | protected: 29 | void closeEvent(QCloseEvent *event) override; 30 | }; 31 | 32 | #endif // WIDGET_H 33 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-4QueuedConnections3/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "producer.h" 6 | #include "consumer.h" 7 | #include 8 | 9 | namespace Ui { 10 | class Widget; 11 | } 12 | 13 | class Widget : public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit Widget(QWidget *parent = nullptr); 19 | ~Widget() override; 20 | 21 | private: 22 | Ui::Widget *ui; 23 | Producer * producer; 24 | Consumer * consumer; 25 | QThread * thread; 26 | 27 | // QWidget interface 28 | protected: 29 | void closeEvent(QCloseEvent *event) override; 30 | }; 31 | 32 | #endif // WIDGET_H 33 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/Server/widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Command to generate xml : /home/gakwaya/Qt5.12.3/5.12.3/gcc_64/bin/qdbuscpp2xml -M -S slavecalculator.h -o slavecalculator.xml 4 | * 5 | * 6 | * 7 | 8 | 9 | * 10 | * */ 11 | 12 | #ifndef WIDGET_H 13 | #define WIDGET_H 14 | 15 | #include 16 | #include "slavecalculator.h" 17 | 18 | namespace Ui { 19 | class Widget; 20 | } 21 | 22 | class Widget : public QWidget 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | explicit Widget(QWidget *parent = nullptr); 28 | ~Widget(); 29 | 30 | private: 31 | Ui::Widget *ui; 32 | SlaveCalculator * slaveCalculator; 33 | }; 34 | 35 | #endif // WIDGET_H 36 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/Server/widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Command to generate xml : /home/gakwaya/Qt5.12.3/5.12.3/gcc_64/bin/qdbuscpp2xml -M -S slavecalculator.h -o slavecalculator.xml 4 | * 5 | * 6 | * 7 | 8 | 9 | * 10 | * */ 11 | 12 | #ifndef WIDGET_H 13 | #define WIDGET_H 14 | 15 | #include 16 | #include "slavecalculator.h" 17 | 18 | namespace Ui { 19 | class Widget; 20 | } 21 | 22 | class Widget : public QWidget 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | explicit Widget(QWidget *parent = nullptr); 28 | ~Widget(); 29 | 30 | private: 31 | Ui::Widget *ui; 32 | SlaveCalculator * slaveCalculator; 33 | }; 34 | 35 | #endif // WIDGET_H 36 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-2ConcurrentRunSync/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | static void heavyWork(); 20 | 21 | private slots: 22 | void on_startButton_clicked(); 23 | 24 | void on_cancelButton_clicked(); 25 | 26 | void on_pauseButton_clicked(); 27 | 28 | void on_resumeButton_clicked(); 29 | 30 | private: 31 | Ui::Widget *ui; 32 | QFuture future; 33 | }; 34 | 35 | #endif // WIDGET_H 36 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-7CuncurrentFilter/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_filterButton_clicked(); 21 | 22 | void on_filterSpinBox_valueChanged(int arg1); 23 | 24 | private: 25 | Ui::Widget *ui; 26 | int filterValue; 27 | QList intList; 28 | QFuture future; 29 | QFutureWatcher futureWatcher; 30 | }; 31 | 32 | #endif // WIDGET_H 33 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-8ConcurrentFiltered/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_filterButton_clicked(); 21 | 22 | void on_filterSpinBox_valueChanged(int arg1); 23 | 24 | private: 25 | Ui::Widget *ui; 26 | int filterValue; 27 | QList intList; 28 | QFuture future; 29 | QFutureWatcher futureWatcher; 30 | }; 31 | 32 | #endif // WIDGET_H 33 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-4ConcurrentMap/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Ui { 9 | class Widget; 10 | } 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | static void modify(int & value); 20 | 21 | private slots: 22 | void on_modifyButton_clicked(); 23 | 24 | void on_seeValuesButton_clicked(); 25 | 26 | private: 27 | Ui::Widget *ui; 28 | QList list; 29 | QFuture future; 30 | QFutureWatcher futureWatcher; 31 | }; 32 | 33 | #endif // WIDGET_H 34 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-5ConcurrentMapped/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Ui { 9 | class Widget; 10 | } 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | static int modify(const int & value); 21 | 22 | private slots: 23 | void on_modifyButton_clicked(); 24 | 25 | void on_seeValuesButton_clicked(); 26 | 27 | private: 28 | Ui::Widget *ui; 29 | QList list; 30 | QFuture future; 31 | QFutureWatcher futureWatcher; 32 | }; 33 | 34 | #endif // WIDGET_H 35 | -------------------------------------------------------------------------------- /6.QProcess/6-1QProcess/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_chooseButton_clicked(); 21 | 22 | void on_startButton_clicked(); 23 | 24 | void on_stopButton_clicked(); 25 | 26 | void finished(int exitCode, QProcess::ExitStatus exitStatus); 27 | 28 | 29 | private: 30 | Ui::Widget *ui; 31 | QString processPath; 32 | QProcess * mProcess; 33 | }; 34 | 35 | #endif // WIDGET_H 36 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-2SynchroQMutex/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "printworker.h" 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | QApplication a(argc, argv); 10 | 11 | bool stopFlag = false; 12 | 13 | QMutex mutex; 14 | 15 | PrintWorker black("Black",&stopFlag,&mutex), white("White",&stopFlag,&mutex); 16 | 17 | 18 | black.start(); 19 | white.start(); 20 | 21 | QMessageBox::information(nullptr,"QMutex", 22 | "Thread working. Close Me to stop"); 23 | 24 | stopFlag = true; 25 | 26 | black.wait(); 27 | white.wait(); 28 | 29 | return 0 ; 30 | } 31 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-3MutexSharedVariable/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "printdevice.h" 4 | #include "printworker.h" 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | 9 | bool stopFlag = false; 10 | 11 | PrintDevice printDevice; 12 | 13 | PrintWorker black("Black",&stopFlag,&printDevice),white("White",&stopFlag,&printDevice); 14 | 15 | black.start(); 16 | white.start(); 17 | 18 | QMessageBox::information(nullptr,"QMutex", 19 | "Thread working. Close Me to stop"); 20 | 21 | stopFlag = true; 22 | 23 | black.wait(); 24 | white.wait(); 25 | 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-2QueuedConnectins1/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 65 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 65 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-4QueuedConnections3/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 143 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /7.IPC/7-4FileProducer/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include 5 | #include 6 | 7 | Widget::Widget(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::Widget) 10 | { 11 | ui->setupUi(this); 12 | setWindowTitle("File Producer"); 13 | 14 | } 15 | 16 | Widget::~Widget() 17 | { 18 | delete ui; 19 | } 20 | 21 | void Widget::on_lineEdit_textChanged(const QString &text) 22 | { 23 | 24 | QFile outFile(QString(QDir::tempPath() + "/sharedFile")); 25 | qDebug() << "File path : " << outFile.fileName(); 26 | outFile.open(QFile::WriteOnly| QIODevice::Append); 27 | QDataStream out(&outFile); 28 | out << text; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-7WaitConditionPauseResume/workerthread.h: -------------------------------------------------------------------------------- 1 | #ifndef WORKERTHREAD_H 2 | #define WORKERTHREAD_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class WorkerThread : public QThread 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit WorkerThread(QObject *parent = nullptr); 13 | ~WorkerThread() override; 14 | 15 | signals: 16 | void currentCount(int value); 17 | 18 | public slots: 19 | void pause(); 20 | void resume(); 21 | 22 | 23 | // QThread interface 24 | protected: 25 | void run() override; 26 | 27 | private: 28 | QMutex m_mutex; 29 | QWaitCondition m_pause_condition; 30 | bool m_pause; 31 | 32 | }; 33 | 34 | #endif // WORKERTHREAD_H 35 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/Client/slavecalculator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/Server/slavecalculator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/Server/widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Command to generate xml : /home/gakwaya/Qt5.12.3/5.12.3/gcc_64/bin/qdbuscpp2xml -M -S slavecalculator.h -o slavecalculator.xml 4 | * 5 | * 6 | * 7 | 8 | 9 | * 10 | * */ 11 | 12 | #ifndef WIDGET_H 13 | #define WIDGET_H 14 | 15 | #include 16 | #include "slavecalculator.h" 17 | 18 | namespace Ui { 19 | class Widget; 20 | } 21 | 22 | class Widget : public QWidget 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | explicit Widget(QWidget *parent = nullptr); 28 | ~Widget(); 29 | 30 | public slots: 31 | void messageSlot(QString message); 32 | 33 | private: 34 | Ui::Widget *ui; 35 | SlaveCalculator * slaveCalculator; 36 | }; 37 | 38 | #endif // WIDGET_H 39 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-1ThreadPoolRunnable/worker.cpp: -------------------------------------------------------------------------------- 1 | #include "worker.h" 2 | #include 3 | #include 4 | 5 | Worker::Worker() 6 | { 7 | qDebug() << "Worker constructor running in thread : " << QThread::currentThread(); 8 | } 9 | 10 | Worker::~Worker(){ 11 | qDebug() << "Worker destructor running in thread : " << QThread::currentThread(); 12 | 13 | } 14 | 15 | void Worker::run() 16 | { 17 | qDebug() << "Worker run method running in thread : " << QThread::currentThread(); 18 | 19 | for(int i{0} ; i < 1000000001 ; i++){ 20 | 21 | if((i%100000) == 0){ 22 | 23 | double percentage = ((i/1000000000.0)) * 100; 24 | qDebug() << "Current percentage : " << percentage; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-7CustomTypeSignals/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include "numberedstring.h" 7 | 8 | namespace Ui { 9 | class Widget; 10 | } 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private slots: 21 | void on_startButton_clicked(); 22 | 23 | void on_infoButton_clicked(); 24 | 25 | void countDone(); 26 | 27 | void currentCount(int value); 28 | 29 | void threadFinished(); 30 | 31 | void currentNumberString(NumberedString ns); 32 | 33 | private: 34 | Ui::Widget *ui; 35 | QThread * workerThread; 36 | }; 37 | 38 | #endif // WIDGET_H 39 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-10FutureSynchronizer/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | static void reduce(int & sum, int value); 20 | 21 | private slots: 22 | void on_filterButton_clicked(); 23 | 24 | void on_filterSpinBox_valueChanged(int arg1); 25 | 26 | private: 27 | Ui::Widget *ui; 28 | int filterValue; 29 | QList intList; 30 | QFuture future; 31 | QFutureWatcher futureWatcher; 32 | 33 | 34 | }; 35 | 36 | #endif // WIDGET_H 37 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-9ConcurrentFilterReduce/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | namespace Ui { 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | static void reduce(int & sum, int value); 20 | 21 | private slots: 22 | void on_filterButton_clicked(); 23 | 24 | void on_filterSpinBox_valueChanged(int arg1); 25 | 26 | private: 27 | Ui::Widget *ui; 28 | int filterValue; 29 | QList intList; 30 | QFuture future; 31 | QFutureWatcher futureWatcher; 32 | 33 | 34 | }; 35 | 36 | #endif // WIDGET_H 37 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-3AsyncSubclassQThread/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | 5 | Widget::Widget(QWidget *parent) : 6 | QWidget(parent), 7 | ui(new Ui::Widget) 8 | { 9 | ui->setupUi(this); 10 | 11 | thread = new WorkerThread(this); 12 | 13 | connect(thread,&WorkerThread::finished,[](){ 14 | qDebug() << "Thread finished"; 15 | }); 16 | } 17 | 18 | Widget::~Widget() 19 | { 20 | delete ui; 21 | } 22 | 23 | void Widget::on_startButton_clicked() 24 | { 25 | thread->start(); 26 | } 27 | 28 | void Widget::on_stopButton_clicked() 29 | { 30 | thread->exit(); 31 | 32 | } 33 | 34 | void Widget::on_infoButton_clicked() 35 | { 36 | qDebug() << "Thread running : " << thread->isRunning(); 37 | } 38 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-3ConcurrentRunAsyc/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Ui { 9 | class Widget; 10 | } 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | static QFuture> heavyWorkWithReturn(); 21 | 22 | private slots: 23 | void on_startButton_clicked(); 24 | 25 | void on_cancelButton_clicked(); 26 | 27 | void on_pauseButton_clicked(); 28 | 29 | void on_resumeButton_clicked(); 30 | 31 | private: 32 | Ui::Widget *ui; 33 | QFuture> future; 34 | QFutureWatcher> watcher; 35 | }; 36 | 37 | #endif // WIDGET_H 38 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-2SynchroQMutex/printworker.cpp: -------------------------------------------------------------------------------- 1 | #include "printworker.h" 2 | #include 3 | #include 4 | 5 | PrintWorker::PrintWorker(QString name, bool * stop, QMutex * mutex, 6 | QObject *parent) : QThread(parent) , 7 | m_name(name), 8 | m_stop(stop), 9 | m_mutex(mutex) 10 | { 11 | 12 | } 13 | 14 | PrintWorker::~PrintWorker() 15 | { 16 | 17 | } 18 | 19 | void PrintWorker::run() 20 | { 21 | while (!(*m_stop)) { 22 | 23 | // m_mutex->lock(); 24 | QMutexLocker locker(m_mutex); 25 | 26 | if(*m_stop){ 27 | // m_mutex->unlock(); 28 | return; 29 | } 30 | 31 | qDebug() << m_name; 32 | sleep(1); 33 | 34 | 35 | //m_mutex->unlock(); 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/producer.cpp: -------------------------------------------------------------------------------- 1 | #include "producer.h" 2 | #include 3 | #include 4 | 5 | Producer::Producer(QWidget *parent) : QPushButton(parent) 6 | { 7 | connect(this,&Producer::clicked,this,&Producer::sendData); 8 | m_integer = 10; 9 | setText("Produce"); 10 | 11 | m_timer = new QTimer(this); 12 | connect(m_timer,&QTimer::timeout,[=](){ 13 | 14 | CustomData cd(22, &m_integer, "Produced data"); 15 | emit data(cd); 16 | 17 | }); 18 | } 19 | 20 | void Producer::sendData() 21 | { 22 | qDebug() << "Producer producing data , thread :" << QThread::currentThread(); 23 | CustomData cd(10, &m_integer, "Produced data"); 24 | emit data(cd); 25 | } 26 | 27 | void Producer::startProduction() 28 | { 29 | m_timer->start(1000); 30 | } 31 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-4QueuedConnections3/producer.cpp: -------------------------------------------------------------------------------- 1 | #include "producer.h" 2 | #include 3 | #include 4 | 5 | Producer::Producer(QWidget *parent) : QPushButton(parent) 6 | { 7 | connect(this,&Producer::clicked,this,&Producer::sendData); 8 | m_integer = 10; 9 | setText("Produce"); 10 | 11 | m_timer = new QTimer(this); 12 | connect(m_timer,&QTimer::timeout,[=](){ 13 | 14 | CustomData cd(22, &m_integer, "Produced data"); 15 | emit data(cd); 16 | 17 | }); 18 | } 19 | 20 | void Producer::sendData() 21 | { 22 | qDebug() << "Producer producing data , thread :" << QThread::currentThread(); 23 | CustomData cd(10, &m_integer, "Produced data"); 24 | emit data(cd); 25 | } 26 | 27 | void Producer::startProduction() 28 | { 29 | m_timer->start(1000); 30 | } 31 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-5SlotsInQThreadSubclass/thread.cpp: -------------------------------------------------------------------------------- 1 | #include "thread.h" 2 | #include 3 | 4 | Thread::Thread(QObject *parent) : QThread(parent), 5 | m_count(0) 6 | { 7 | qDebug() << "Thread constructor on thread : " << QThread::currentThread(); 8 | } 9 | 10 | void Thread::increment() 11 | { 12 | qDebug() << "Increment called on thread : " << QThread::currentThread(); 13 | m_count++; 14 | 15 | if(m_count == 5){ 16 | m_timer->stop(); 17 | thread()->quit(); 18 | } 19 | 20 | } 21 | 22 | void Thread::run() { 23 | //Managed thread 24 | 25 | qDebug() << "Run called on thread : " << QThread::currentThread(); 26 | m_timer = new QTimer(); 27 | connect(m_timer,&QTimer::timeout,this,&Thread::increment); 28 | m_timer->start(1000); 29 | exec(); 30 | } 31 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-5SynchronizationSemaphone/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "producer.h" 8 | #include "consumer.h" 9 | 10 | const int BUFFER_SIZE = 6; 11 | 12 | namespace Ui { 13 | class Widget; 14 | } 15 | 16 | class Widget : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit Widget(QWidget *parent = nullptr); 22 | ~Widget(); 23 | 24 | private slots: 25 | void on_startButton_clicked(); 26 | 27 | private: 28 | Ui::Widget *ui; 29 | bool atEnd; 30 | QSemaphore * freeSpace; 31 | QSemaphore * avSpace; 32 | QVector dataSource; 33 | int bufferArray [BUFFER_SIZE]; 34 | Producer * producer; 35 | Consumer * consumer; 36 | }; 37 | 38 | #endif // WIDGET_H 39 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-5SynchronizationSemaphone/consumer.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSUMER_H 2 | #define CONSUMER_H 3 | 4 | #include 5 | #include 6 | 7 | class Consumer : public QThread 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit Consumer(int *buffer, int bufferSize,QSemaphore * freeSpace, 12 | QSemaphore * availableSpace, 13 | bool * atEnd,QObject *parent = nullptr); 14 | 15 | signals: 16 | 17 | public slots: 18 | 19 | // QThread interface 20 | protected: 21 | void run() override; 22 | 23 | private: 24 | int * m_buffer; 25 | int m_BUFFER_SIZE; 26 | QSemaphore * m_free_space;// Space where the producer can write data 27 | QSemaphore * m_available_space;//Space where consumer can read data from 28 | bool * m_at_end; 29 | }; 30 | 31 | #endif // CONSUMER_H 32 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-6SynchronizationWaitConditions/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | 4 | Widget::Widget(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::Widget) 7 | { 8 | ui->setupUi(this); 9 | 10 | totalData = 100000; 11 | usedSlots = 0; 12 | 13 | 14 | producer = new Producer(buffer,M_BUFFER_SIZE,&usedSlots,totalData, 15 | &mutex,&bufferFull,&bufferEmpty); 16 | 17 | consumer = new Consumer(buffer,M_BUFFER_SIZE,&usedSlots,totalData, 18 | &mutex,&bufferFull,&bufferEmpty); 19 | 20 | } 21 | 22 | Widget::~Widget() 23 | { 24 | delete ui; 25 | } 26 | 27 | void Widget::on_startButton_clicked() 28 | { 29 | producer->start(); 30 | consumer->start(); 31 | 32 | producer->wait(); 33 | consumer->wait(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/Server/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 140 20 | 120 21 | 67 22 | 17 23 | 24 | 25 | 26 | Server 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-6SynchronizationWaitConditions/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "producer.h" 8 | #include "consumer.h" 9 | 10 | namespace Ui { 11 | class Widget; 12 | } 13 | 14 | const int M_BUFFER_SIZE = 6000; 15 | 16 | class Widget : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit Widget(QWidget *parent = nullptr); 22 | ~Widget(); 23 | 24 | private slots: 25 | void on_startButton_clicked(); 26 | 27 | private: 28 | Ui::Widget *ui; 29 | 30 | int totalData; 31 | char buffer[M_BUFFER_SIZE]; 32 | QWaitCondition bufferFull; 33 | QWaitCondition bufferEmpty; 34 | QMutex mutex; 35 | int usedSlots; 36 | Producer * producer; 37 | Consumer * consumer; 38 | }; 39 | 40 | #endif // WIDGET_H 41 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/Server/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 140 20 | 120 21 | 67 22 | 17 23 | 24 | 25 | 26 | Server 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/Server/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 140 20 | 120 21 | 67 22 | 17 23 | 24 | 25 | 26 | Server 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /7.IPC/7-4FileConsumer/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | File Consumer 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /7.IPC/7-4FileProducer/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 65 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | File Producer 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/Server/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 140 20 | 120 21 | 67 22 | 17 23 | 24 | 25 | 26 | Server 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-2QThreadCreate/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 150 20 | 110 21 | 93 22 | 28 23 | 24 | 25 | 26 | Start 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-1AsyncQThreadCreate/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 140 20 | 120 21 | 93 22 | 28 23 | 24 | 25 | 26 | Start 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_CXX.QT_COMPILER_STDCXX = 199711L 2 | QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 5 3 | QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 4 4 | QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 5 | QMAKE_CXX.COMPILER_MACROS = \ 6 | QT_COMPILER_STDCXX \ 7 | QMAKE_GCC_MAJOR_VERSION \ 8 | QMAKE_GCC_MINOR_VERSION \ 9 | QMAKE_GCC_PATCH_VERSION 10 | QMAKE_CXX.INCDIRS = \ 11 | /usr/include/c++/5 \ 12 | /usr/include/x86_64-linux-gnu/c++/5 \ 13 | /usr/include/c++/5/backward \ 14 | /usr/lib/gcc/x86_64-linux-gnu/5/include \ 15 | /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed \ 16 | /usr/include/x86_64-linux-gnu \ 17 | /usr/include 18 | QMAKE_CXX.LIBDIRS = \ 19 | /usr/lib/gcc/x86_64-linux-gnu/5 \ 20 | /usr/lib/x86_64-linux-gnu \ 21 | /usr/lib \ 22 | /lib/x86_64-linux-gnu \ 23 | /lib 24 | -------------------------------------------------------------------------------- /7.IPC/7-3TcpServer/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | TCP Data receiver using QTCPServer 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-3AsyncSubclassQThread/workerthread.cpp: -------------------------------------------------------------------------------- 1 | #include "workerthread.h" 2 | #include 3 | #include 4 | 5 | WorkerThread::WorkerThread(QObject *parent) : QThread(parent) 6 | { 7 | qDebug () << "Worker thread constructor running in thread : " << QThread::currentThread(); 8 | 9 | } 10 | 11 | WorkerThread::~ WorkerThread() { 12 | qDebug () << "Worker thread destructor running in thread : " << QThread::currentThread(); 13 | 14 | } 15 | 16 | void WorkerThread:: run() { 17 | 18 | qDebug () << "Workerthread run method running in thread : " << QThread::currentThread(); 19 | 20 | 21 | QTimer * timer = new QTimer(); 22 | connect(timer,&QTimer::timeout,[](){ 23 | qDebug() << "Time out . Running in thread : " << QThread::currentThread(); 24 | }); 25 | timer->setInterval(1000); 26 | timer->start(); 27 | 28 | exec(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-5SynchronizationSemaphone/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 140 20 | 100 21 | 93 22 | 28 23 | 24 | 25 | 26 | Start 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_GCC_64bit-Debug/Server/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_CXX.QT_COMPILER_STDCXX = 199711L 2 | QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 5 3 | QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 4 4 | QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 5 | QMAKE_CXX.COMPILER_MACROS = \ 6 | QT_COMPILER_STDCXX \ 7 | QMAKE_GCC_MAJOR_VERSION \ 8 | QMAKE_GCC_MINOR_VERSION \ 9 | QMAKE_GCC_PATCH_VERSION 10 | QMAKE_CXX.INCDIRS = \ 11 | /usr/include/c++/5 \ 12 | /usr/include/x86_64-linux-gnu/c++/5 \ 13 | /usr/include/c++/5/backward \ 14 | /usr/lib/gcc/x86_64-linux-gnu/5/include \ 15 | /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed \ 16 | /usr/include/x86_64-linux-gnu \ 17 | /usr/include 18 | QMAKE_CXX.LIBDIRS = \ 19 | /usr/lib/gcc/x86_64-linux-gnu/5 \ 20 | /usr/lib/x86_64-linux-gnu \ 21 | /usr/lib \ 22 | /lib/x86_64-linux-gnu \ 23 | /lib 24 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-5SynchronizationSemaphone/consumer.cpp: -------------------------------------------------------------------------------- 1 | #include "consumer.h" 2 | #include 3 | 4 | Consumer::Consumer(int *buffer, int bufferSize,QSemaphore * freeSpace, 5 | QSemaphore * availableSpace, 6 | bool * atEnd,QObject *parent) : 7 | QThread(parent), 8 | m_buffer(buffer),m_BUFFER_SIZE(bufferSize), 9 | m_free_space(freeSpace), 10 | m_available_space(availableSpace), 11 | m_at_end(atEnd) 12 | { 13 | 14 | } 15 | 16 | void Consumer::run() 17 | { 18 | 19 | int i{0}; 20 | 21 | while(!(*m_at_end) || m_available_space->available()){ 22 | m_available_space->acquire(); 23 | //READ DATA 24 | 25 | qDebug() << "[" << i << "]" << m_buffer[i];//Consume data 26 | 27 | i =((i+1) % (m_BUFFER_SIZE)); 28 | 29 | m_free_space->release(); 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-6SynchronizationWaitConditions/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 140 20 | 110 21 | 93 22 | 28 23 | 24 | 25 | 26 | Start 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-4SynchronizationReadWriteLock/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "printdevice.h" 4 | #include "printworker.h" 5 | #include "incrementworker.h" 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | QApplication a(argc, argv); 10 | 11 | bool stopFlag = false; 12 | 13 | PrintDevice printDevice; 14 | 15 | PrintWorker white("White",&stopFlag,&printDevice),black("Black",&stopFlag,&printDevice); 16 | 17 | IncrementWorker incrementWorker(&stopFlag,&printDevice); 18 | 19 | 20 | white.start(); 21 | black.start(); 22 | incrementWorker.start(); 23 | 24 | QMessageBox::information(nullptr,"QMutex", 25 | "Thread working. Close Me to stop"); 26 | 27 | stopFlag = true; 28 | 29 | white.wait(); 30 | black.wait(); 31 | incrementWorker.wait(); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /7.IPC/7-3TcpClient/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 414 10 | 65 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | TcpClient. Will send data to the server using TCP 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-7WaitConditionPauseResume/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | 5 | Widget::Widget(QWidget *parent) : 6 | QWidget(parent), 7 | ui(new Ui::Widget) 8 | { 9 | ui->setupUi(this); 10 | 11 | qDebug() << "Ui thread : " << QThread::currentThread(); 12 | 13 | workerThread = new WorkerThread(this); 14 | connect(workerThread,&WorkerThread::currentCount,this,&Widget::currentCount); 15 | 16 | } 17 | 18 | Widget::~Widget() 19 | { 20 | delete ui; 21 | } 22 | 23 | void Widget::on_startButton_clicked() 24 | { 25 | workerThread->start(); 26 | } 27 | 28 | void Widget::on_pauseButton_clicked() 29 | { 30 | workerThread->pause(); 31 | } 32 | 33 | void Widget::on_resumeButton_clicked() 34 | { 35 | workerThread->resume(); 36 | } 37 | 38 | void Widget::currentCount(int value) 39 | { 40 | ui->progressBar->setValue(value); 41 | } 42 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-5SynchronizationSemaphone/producer.cpp: -------------------------------------------------------------------------------- 1 | #include "producer.h" 2 | 3 | Producer::Producer(const QVector & dataSource, int * buffer, 4 | int bufferSize,QSemaphore *freeSpace, 5 | QSemaphore *availableSpace, bool *atEnd,QObject *parent) : 6 | QThread(parent), 7 | m_data_source(dataSource), 8 | m_buffer(buffer), 9 | m_BUFFER_SIZE(bufferSize), 10 | m_free_space(freeSpace), 11 | m_available_space(availableSpace), 12 | m_at_end(atEnd) 13 | { 14 | 15 | } 16 | 17 | void Producer::run() 18 | { 19 | for(int i{0} ; i < m_data_source.length() ; i++){ 20 | 21 | m_free_space->acquire(); 22 | //WRITE DATA 23 | 24 | m_buffer[ i % m_BUFFER_SIZE] = m_data_source.at(i); 25 | 26 | if(i == m_data_source.length() -1) 27 | *m_at_end = true; 28 | 29 | 30 | m_available_space->release(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-6SynchronizationWaitConditions/producer.h: -------------------------------------------------------------------------------- 1 | #ifndef PRODUCER_H 2 | #define PRODUCER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class Producer : public QThread 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit Producer(char * buffer, int bufferSize, 13 | int * usedSlots, int totalData, 14 | QMutex * mutex, 15 | QWaitCondition * bufferFull,QWaitCondition * bufferEmpty, 16 | QObject *parent = nullptr); 17 | 18 | signals: 19 | 20 | public slots: 21 | 22 | // QThread interface 23 | protected: 24 | void run() override; 25 | 26 | private: 27 | char * m_buffer; 28 | int m_buffer_size; 29 | int * m_used_slots; 30 | int m_total_data; 31 | QMutex * m_mutex; 32 | QWaitCondition * m_buffer_full; 33 | QWaitCondition * m_buffer_empty; 34 | }; 35 | 36 | #endif // PRODUCER_H 37 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/Client/slavecalculator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/Server/slavecalculator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/Client/slavecalculator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/Server/slavecalculator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/Client/slavecalculator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/Server/slavecalculator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/Client/calculatorINterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.8 3 | * Command line was: qdbusxml2cpp -p calculatorINterface slavecalculator.xml 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2019 The Qt Company Ltd. 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #include "calculatorINterface.h" 13 | 14 | /* 15 | * Implementation of interface class ComBlikoonCalculatorInterfaceInterface 16 | */ 17 | 18 | ComBlikoonCalculatorInterfaceInterface::ComBlikoonCalculatorInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) 19 | : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) 20 | { 21 | } 22 | 23 | ComBlikoonCalculatorInterfaceInterface::~ComBlikoonCalculatorInterfaceInterface() 24 | { 25 | } 26 | 27 | -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/Client/calculatorINterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.8 3 | * Command line was: qdbusxml2cpp -p calculatorINterface slavecalculator.xml 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2019 The Qt Company Ltd. 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #include "calculatorINterface.h" 13 | 14 | /* 15 | * Implementation of interface class ComBlikoonCalculatorInterfaceInterface 16 | */ 17 | 18 | ComBlikoonCalculatorInterfaceInterface::ComBlikoonCalculatorInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) 19 | : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) 20 | { 21 | } 22 | 23 | ComBlikoonCalculatorInterfaceInterface::~ComBlikoonCalculatorInterfaceInterface() 24 | { 25 | } 26 | 27 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/Client/calculatorINterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.8 3 | * Command line was: qdbusxml2cpp -p calculatorINterface slavecalculator.xml 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2019 The Qt Company Ltd. 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #include "calculatorINterface.h" 13 | 14 | /* 15 | * Implementation of interface class ComBlikoonCalculatorInterfaceInterface 16 | */ 17 | 18 | ComBlikoonCalculatorInterfaceInterface::ComBlikoonCalculatorInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) 19 | : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) 20 | { 21 | } 22 | 23 | ComBlikoonCalculatorInterfaceInterface::~ComBlikoonCalculatorInterfaceInterface() 24 | { 25 | } 26 | 27 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-5SynchronizationSemaphone/producer.h: -------------------------------------------------------------------------------- 1 | #ifndef PRODUCER_H 2 | #define PRODUCER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class Producer : public QThread 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit Producer(const QVector & dataSource, 13 | int * buffer,int bufferSize,QSemaphore * freeSpace, 14 | QSemaphore * availableSpace, 15 | bool * atEnd,QObject *parent = nullptr); 16 | 17 | signals: 18 | 19 | public slots: 20 | 21 | // QThread interface 22 | protected: 23 | void run() override; 24 | 25 | private: 26 | QVector m_data_source; 27 | int * m_buffer; 28 | int m_BUFFER_SIZE; 29 | QSemaphore * m_free_space;// Space where the producer can write data 30 | QSemaphore * m_available_space;//Space where consumer can read data from 31 | bool * m_at_end; 32 | }; 33 | 34 | #endif // PRODUCER_H 35 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-6SynchronizationWaitConditions/consumer.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSUMER_H 2 | #define CONSUMER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class Consumer : public QThread 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit Consumer(char * buffer, int bufferSize, 13 | int * usedSlots, int totalData, 14 | QMutex * mutex, 15 | QWaitCondition * bufferFull,QWaitCondition * bufferEmpty, 16 | QObject *parent = nullptr); 17 | 18 | signals: 19 | 20 | public slots: 21 | 22 | // QThread interface 23 | protected: 24 | void run() override; 25 | 26 | private: 27 | char * m_buffer; 28 | int m_buffer_size; 29 | int * m_used_slots; 30 | int m_total_data; 31 | QMutex * m_mutex; 32 | QWaitCondition * m_buffer_full; 33 | QWaitCondition * m_buffer_empty; 34 | 35 | }; 36 | 37 | #endif // CONSUMER_H 38 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/Client/calculatorInterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.8 3 | * Command line was: qdbusxml2cpp -p calculatorInterface slavecalculator.xml 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2019 The Qt Company Ltd. 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #include "calculatorInterface.h" 13 | 14 | /* 15 | * Implementation of interface class ComBlikoonCalculatorInterfaceInterface 16 | */ 17 | 18 | ComBlikoonCalculatorInterfaceInterface::ComBlikoonCalculatorInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) 19 | : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) 20 | { 21 | } 22 | 23 | ComBlikoonCalculatorInterfaceInterface::~ComBlikoonCalculatorInterfaceInterface() 24 | { 25 | } 26 | 27 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-5SynchronizationSemaphone/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | 4 | Widget::Widget(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::Widget) 7 | { 8 | ui->setupUi(this); 9 | 10 | dataSource << 1 << 2 << 34 <<55 << 4<< 11 << 22 << 34 <<55 << 11 | 4<< 1 << 2 << 34 <<55 << 4<< 1 << 2 << 34 <<55 << 4<<2222; 12 | 13 | atEnd = false; 14 | 15 | 16 | freeSpace = new QSemaphore(BUFFER_SIZE); 17 | 18 | avSpace = new QSemaphore(0); 19 | 20 | producer = new Producer(dataSource,bufferArray,BUFFER_SIZE,freeSpace,avSpace,&atEnd); 21 | consumer = new Consumer(bufferArray,BUFFER_SIZE,freeSpace,avSpace,&atEnd); 22 | } 23 | 24 | Widget::~Widget() 25 | { 26 | delete ui; 27 | } 28 | 29 | void Widget::on_startButton_clicked() 30 | { 31 | producer->start(); 32 | consumer->start(); 33 | 34 | producer->wait(); 35 | consumer->wait(); 36 | 37 | atEnd = false; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-3MoveToThread/worker.cpp: -------------------------------------------------------------------------------- 1 | #include "worker.h" 2 | #include 3 | #include 4 | #include 5 | 6 | Worker::Worker(QObject *parent) : QObject(parent) 7 | { 8 | qDebug() << "Worker constructor running in thread : " << QThread::currentThread(); 9 | } 10 | 11 | Worker::~Worker() 12 | { 13 | qDebug() << "Worker destroyed, destructor running in thread : " << QThread::currentThread(); 14 | } 15 | 16 | void Worker::doCounting() 17 | { 18 | 19 | qDebug() << "Worker counting method running in thread : " << QThread::currentThread(); 20 | //Code here is going to run in secondary/background thread 21 | 22 | for(int i{0} ; i < 1000000001 ; i++){ 23 | 24 | double percentage = (i/ 1000000000.0) * 100.0; 25 | 26 | //qDebug() << "Percentage : " << percentage; 27 | 28 | if((i% 100000) ==0){ 29 | emit currentCount(QVariant::fromValue(percentage).toInt()); 30 | } 31 | } 32 | emit countDone(); 33 | } 34 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-4ConcurrentMap/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 90 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | Modify 21 | 22 | 23 | 24 | 25 | 26 | 27 | Seee values 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-5ConcurrentMapped/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 85 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | Modify 21 | 22 | 23 | 24 | 25 | 26 | 27 | See values 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-1AsyncQThreadCreate/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include 5 | 6 | Widget::Widget(QWidget *parent) : 7 | QWidget(parent), 8 | ui(new Ui::Widget) 9 | { 10 | ui->setupUi(this); 11 | qDebug() << "Ui thread : " << QThread::currentThread(); 12 | 13 | thread = QThread::create([](){ 14 | 15 | QTimer * timer = new QTimer(); 16 | connect(timer,&QTimer::timeout,[](){ 17 | qDebug() << "Time out . Running in thread : " << QThread::currentThread(); 18 | }); 19 | timer->start(1000); 20 | 21 | }); 22 | 23 | connect(thread,&QThread::started,[](){ 24 | qDebug() << "Thread started"; 25 | }); 26 | 27 | connect(thread,&QThread::finished,[](){ 28 | qDebug() << "Thread finished"; 29 | }); 30 | 31 | // thread->start(); 32 | } 33 | 34 | Widget::~Widget() 35 | { 36 | delete ui; 37 | } 38 | 39 | void Widget::on_startButton_clicked() 40 | { 41 | thread->start(); 42 | } 43 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-4SubclassQThread/workerthread.cpp: -------------------------------------------------------------------------------- 1 | #include "workerthread.h" 2 | #include 3 | 4 | WorkerThread::WorkerThread(QObject *parent) : QThread(parent) 5 | { 6 | qDebug() << "Worker thread constructor running in thread : " << QThread::currentThread(); 7 | } 8 | 9 | WorkerThread::~WorkerThread() 10 | { 11 | qDebug() << "Worker thread destructor running in thread : " << QThread::currentThread(); 12 | } 13 | 14 | void WorkerThread::run() 15 | { 16 | qDebug() << "Run method of thread running in thread : " << QThread::currentThread(); 17 | 18 | for(int i{0} ; i < 1000000001 ; i++){ 19 | /* 20 | * Only emit signal to send info to ui at 100000 intervals. UI can handle this. 21 | * Otherwise it is going to freeze. 22 | * */ 23 | if((i%100000) == 0){ 24 | double percentage = ((i/1000000000.0)) * 100; 25 | emit currentCount(QVariant::fromValue(percentage).toInt()); 26 | } 27 | } 28 | 29 | //Start event loop 30 | //exec() ; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-3QueuedConnections2/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include 5 | #include 6 | 7 | Widget::Widget(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::Widget) 10 | { 11 | ui->setupUi(this); 12 | 13 | qDebug() << "Ui thread : " << QThread::currentThread(); 14 | 15 | producer = new Producer(this); 16 | ui->verticalLayout->addWidget(producer); 17 | 18 | consumer = new Consumer(); 19 | 20 | thread = new Thread(producer); 21 | 22 | connect(thread,&QThread::finished,[=](){ 23 | qDebug() << "Application about to be killed , thread : " << QThread::currentThread(); 24 | QApplication::quit(); 25 | 26 | }); 27 | 28 | thread->start(); 29 | 30 | producer->startProduction(); 31 | 32 | 33 | } 34 | 35 | Widget::~Widget() 36 | { 37 | delete ui; 38 | } 39 | 40 | void Widget::closeEvent(QCloseEvent *event) 41 | { 42 | //Quit thread before killing app 43 | thread->quit(); 44 | 45 | event->accept(); 46 | } 47 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-4QueuedConnections3/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include 5 | #include 6 | 7 | Widget::Widget(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::Widget) 10 | { 11 | ui->setupUi(this); 12 | 13 | qDebug() << "Ui thread : " << QThread::currentThread(); 14 | 15 | producer = new Producer(this); 16 | ui->verticalLayout->addWidget(producer); 17 | 18 | consumer = new Consumer(); 19 | 20 | thread = new QThread(this); 21 | 22 | connect(producer, &Producer::data, consumer, &Consumer::data); 23 | connect(thread,&QThread::started,producer,&Producer::startProduction); 24 | connect(thread, &QThread::finished,consumer, &QObject::deleteLater); 25 | 26 | consumer->moveToThread(thread); 27 | 28 | thread->start(); 29 | 30 | } 31 | 32 | Widget::~Widget() 33 | { 34 | delete ui; 35 | } 36 | 37 | void Widget::closeEvent(QCloseEvent *event) 38 | { 39 | //Quit thread before killing app 40 | thread->quit(); 41 | 42 | event->accept(); 43 | } 44 | -------------------------------------------------------------------------------- /7.IPC/7-3TcpClient/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include 5 | 6 | Widget::Widget(QWidget *parent) : 7 | QWidget(parent), 8 | ui(new Ui::Widget), 9 | m_socket(new QTcpSocket(this)), 10 | m_socketReady(false) 11 | 12 | { 13 | ui->setupUi(this); 14 | 15 | setWindowTitle("Client | Data Sender"); 16 | 17 | m_socket->connectToHost("localhost", 4040); 18 | 19 | connect(m_socket, &QTcpSocket::connected, this, &Widget::socketReady); 20 | connect(m_socket,&QTcpSocket::stateChanged,this,&Widget::stateChanged); 21 | 22 | } 23 | 24 | Widget::~Widget() 25 | { 26 | m_socket->close(); 27 | delete ui; 28 | } 29 | 30 | void Widget::socketReady() 31 | { 32 | m_socketReady = true; 33 | } 34 | 35 | void Widget::stateChanged(QAbstractSocket::SocketState socketState) 36 | { 37 | qDebug() << socketState; 38 | } 39 | 40 | void Widget::on_lineEdit_textChanged(const QString &newText) 41 | { 42 | if(m_socketReady){ 43 | QDataStream out(m_socket); 44 | out << newText; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-2AsyncMoveToThread/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include "worker.h" 4 | #include 5 | #include 6 | 7 | Widget::Widget(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::Widget) 10 | { 11 | ui->setupUi(this); 12 | 13 | qDebug() << "Ui thread : " << QThread::currentThread(); 14 | 15 | thread = new QThread(this); 16 | 17 | 18 | } 19 | 20 | Widget::~Widget() 21 | { 22 | delete ui; 23 | } 24 | 25 | void Widget::on_startButton_clicked() 26 | { 27 | Worker * worker = new Worker; 28 | 29 | worker->moveToThread(thread); 30 | 31 | connect(thread,&QThread::started,worker,&Worker::doWork); 32 | connect(thread,&QThread::finished,[](){ 33 | qDebug() << "Thread finished"; 34 | }); 35 | connect(thread,&QThread::finished,worker,&Worker::deleteLater); 36 | 37 | thread->start(); 38 | 39 | } 40 | 41 | void Widget::on_stopButton_clicked() 42 | { 43 | thread->exit(); 44 | } 45 | 46 | void Widget::on_infoButton_clicked() 47 | { 48 | qDebug() << "Thread running : " << thread->isRunning(); 49 | } 50 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-1ThreadPoolRunnable/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 52 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Start 23 | 24 | 25 | 26 | 27 | 28 | 29 | Info 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-2SynchroQMutex/3-2SynchroQMutex.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++11 console 6 | 7 | # The following define makes your compiler emit warnings if you use 8 | # any Qt feature that has been marked deprecated (the exact warnings 9 | # depend on your compiler). Please consult the documentation of the 10 | # deprecated API in order to know how to port your code away from it. 11 | DEFINES += QT_DEPRECATED_WARNINGS 12 | 13 | # You can also make your code fail to compile if it uses deprecated APIs. 14 | # In order to do so, uncomment the following line. 15 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 17 | 18 | SOURCES += \ 19 | main.cpp \ 20 | printworker.cpp 21 | 22 | # Default rules for deployment. 23 | qnx: target.path = /tmp/$${TARGET}/bin 24 | else: unix:!android: target.path = /opt/$${TARGET}/bin 25 | !isEmpty(target.path): INSTALLS += target 26 | 27 | HEADERS += \ 28 | printworker.h 29 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-4SubclassQThread/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include 5 | 6 | Widget::Widget(QWidget *parent) : 7 | QWidget(parent), 8 | ui(new Ui::Widget) 9 | { 10 | ui->setupUi(this); 11 | 12 | qDebug() << "Ui thread : " << QThread::currentThread(); 13 | 14 | workerThread = new WorkerThread(this); 15 | connect(workerThread,&WorkerThread::currentCount,this,&Widget::currentCount); 16 | 17 | connect(workerThread,&QThread::started,[](){ 18 | qDebug() << "Thread started"; 19 | }); 20 | 21 | connect(workerThread,&QThread::finished,[](){ 22 | qDebug() << "Thread finished"; 23 | }); 24 | } 25 | 26 | Widget::~Widget() 27 | { 28 | delete ui; 29 | } 30 | 31 | void Widget::on_startButton_clicked() 32 | { 33 | workerThread->start(); 34 | } 35 | 36 | void Widget::on_infoButton_clicked() 37 | { 38 | qDebug() << "Thread is running : " << workerThread->isRunning(); 39 | } 40 | 41 | void Widget::currentCount(int value){ 42 | 43 | ui->progressBar->setValue(value); 44 | ui->infoLabel->setText(QString::number(value)); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-7CustomTypeSignals/worker.cpp: -------------------------------------------------------------------------------- 1 | #include "worker.h" 2 | #include 3 | #include 4 | #include 5 | 6 | Worker::Worker(QObject *parent) : QObject(parent) 7 | { 8 | qDebug() << "Worker constructor running in thread : " << QThread::currentThread(); 9 | } 10 | 11 | Worker::~Worker() 12 | { 13 | qDebug() << "Worker destroyed, destructor running in thread : " << QThread::currentThread(); 14 | } 15 | 16 | void Worker::doCounting() 17 | { 18 | 19 | qDebug() << "Worker counting method running in thread : " << QThread::currentThread(); 20 | //Code here is going to run in secondary/background thread 21 | 22 | for(int i{0} ; i < 1000000001 ; i++){ 23 | 24 | double percentage = (i/ 1000000000.0) * 100.0; 25 | 26 | //qDebug() << "Percentage : " << percentage; 27 | 28 | if((i% 100000) ==0){ 29 | 30 | QString txt = "Hello " +QString::number(QVariant::fromValue(percentage).toInt()); 31 | 32 | NumberedString ns(QVariant::fromValue(percentage).toInt(),txt); 33 | 34 | emit currentNumberString(ns); 35 | } 36 | } 37 | emit countDone(); 38 | } 39 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/Server/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include "calculatoradaptor.h" 4 | 5 | Widget::Widget(QWidget *parent) : 6 | QWidget(parent), 7 | ui(new Ui::Widget) 8 | { 9 | ui->setupUi(this); 10 | 11 | //Create actual calculator 12 | slaveCalculator = new SlaveCalculator(this); 13 | 14 | 15 | //Adaptor is used in the class exposing the service. 16 | //You have to pass the object you want to expose to DBus in the parameter 17 | //because methods will be called on it 18 | new CalculatorInterfaceAdaptor(slaveCalculator); 19 | 20 | 21 | 22 | QDBusConnection connection = QDBusConnection::sessionBus(); 23 | 24 | //Here you pass in the object that you want expose to Dbus. Take note of this info, it is used in client. 25 | connection.registerObject("/CalcServicePath", slaveCalculator); 26 | 27 | //Here you pass in the service name. Take note of this as it is also needed for clients to reach our exposed object. 28 | connection.registerService("com.blikoon.CalculatorService"); 29 | } 30 | 31 | Widget::~Widget() 32 | { 33 | delete ui; 34 | } 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/Server/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include "calculatoradaptor.h" 4 | 5 | Widget::Widget(QWidget *parent) : 6 | QWidget(parent), 7 | ui(new Ui::Widget) 8 | { 9 | ui->setupUi(this); 10 | 11 | //Create actual calculator 12 | slaveCalculator = new SlaveCalculator(this); 13 | 14 | 15 | //Adaptor is used in the class exposing the service. 16 | //You have to pass the object you want to expose to DBus in the parameter 17 | //because methods will be called on it 18 | new CalculatorInterfaceAdaptor(slaveCalculator); 19 | 20 | 21 | 22 | QDBusConnection connection = QDBusConnection::sessionBus(); 23 | 24 | //Here you pass in the object that you want expose to Dbus. Take note of this info, it is used in client. 25 | connection.registerObject("/CalcServicePath", slaveCalculator); 26 | 27 | //Here you pass in the service name. Take note of this as it is also needed for clients to reach our exposed object. 28 | connection.registerService("com.blikoon.CalculatorService"); 29 | } 30 | 31 | Widget::~Widget() 32 | { 33 | delete ui; 34 | } 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-3ThreadPoolAsync/worker.cpp: -------------------------------------------------------------------------------- 1 | #include "worker.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "progressevent.h" 9 | 10 | Worker::Worker(QObject * receiver) : m_receiver(receiver) 11 | { 12 | qDebug() << "Worker constructor running in thread : " << QThread::currentThread(); 13 | } 14 | 15 | Worker::~Worker(){ 16 | qDebug() << "Worker destructor running in thread : " << QThread::currentThread(); 17 | 18 | } 19 | 20 | void Worker::run() 21 | { 22 | qDebug() << "Worker run method running in thread : " << QThread::currentThread(); 23 | 24 | //Because there is no event loop in the threads in here, you can't run async code 25 | // like QTimer or TCPSocket . If you do, the thread just exits and finishes 26 | //without doing nothing. 27 | 28 | QTimer * timer = new QTimer(); 29 | QObject::connect(timer,&QTimer::timeout,[](){ 30 | qDebug() << "Time out . Running in thread : " << QThread::currentThread(); 31 | }); 32 | timer->setInterval(1000); 33 | timer->start(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-6SynchronizationWaitConditions/consumer.cpp: -------------------------------------------------------------------------------- 1 | #include "consumer.h" 2 | #include 3 | 4 | Consumer::Consumer(char * buffer, int bufferSize, 5 | int * usedSlots, int totalData, 6 | QMutex * mutex, 7 | QWaitCondition * bufferFull,QWaitCondition * bufferEmpty, 8 | QObject *parent) : QThread(parent), 9 | m_buffer(buffer), m_buffer_size(bufferSize), 10 | m_used_slots(usedSlots),m_total_data(totalData), 11 | m_mutex(mutex), 12 | m_buffer_full(bufferFull), 13 | m_buffer_empty(bufferEmpty) 14 | { 15 | 16 | } 17 | void Consumer::run(){ 18 | 19 | for (int i = 0; i < m_total_data; ++i) { 20 | m_mutex->lock(); 21 | 22 | if((*m_used_slots) == 0){ 23 | m_buffer_empty->wait(m_mutex);//FREEZE CODE EXECUTION IN THE THEAD 24 | } 25 | 26 | m_mutex->unlock(); 27 | 28 | //Write data to console 29 | qDebug() << "Consumer data : " << m_buffer[i % m_buffer_size]; 30 | 31 | 32 | m_mutex->lock(); 33 | --(*m_used_slots); 34 | m_buffer_full->wakeAll(); 35 | m_mutex->unlock(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /4.ThreadSafetyReentrancy/4-2QueuedConnectins1/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include 5 | #include 6 | 7 | Widget::Widget(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::Widget) 10 | { 11 | ui->setupUi(this); 12 | 13 | qDebug() << "Ui thread : " << QThread::currentThread(); 14 | 15 | producer = new Producer(this); 16 | ui->verticalLayout->addWidget(producer); 17 | 18 | consumer = new Consumer(); 19 | 20 | thread = new QThread(this); 21 | 22 | connect(thread,&QThread::finished,[=](){ 23 | qDebug() << "Application about to be killed , thread : " << QThread::currentThread(); 24 | QApplication::quit(); 25 | 26 | }); 27 | 28 | 29 | //Do queued connection 30 | connect(producer,&Producer::data,consumer,&Consumer::data); 31 | 32 | consumer->moveToThread(thread); 33 | 34 | 35 | thread->start(); 36 | 37 | 38 | } 39 | 40 | Widget::~Widget() 41 | { 42 | delete ui; 43 | } 44 | 45 | void Widget::closeEvent(QCloseEvent *event) 46 | { 47 | //Quit thread before killing app 48 | thread->quit(); 49 | 50 | event->accept(); 51 | } 52 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/Server/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include "calculatoradaptor.h" 4 | 5 | Widget::Widget(QWidget *parent) : 6 | QWidget(parent), 7 | ui(new Ui::Widget) 8 | { 9 | ui->setupUi(this); 10 | 11 | //Create actual calculator 12 | slaveCalculator = new SlaveCalculator(this); 13 | 14 | 15 | //Adaptor is used in the class exposing the service. 16 | //You have to pass the object you want to expose to DBus in the parameter 17 | //because methods will be called on it 18 | 19 | 20 | new CalculatorInterfaceAdaptor(slaveCalculator); 21 | 22 | QDBusConnection connection = QDBusConnection::sessionBus(); 23 | 24 | //Here you pass in the object that you want expose to Dbus. 25 | //Take note of this info, it is used in client. 26 | connection.registerObject("/CalcServicePath", slaveCalculator); 27 | 28 | //Here you pass in the service name. 29 | //Take note of this as it is also needed for clients to reach our exposed object. 30 | connection.registerService("com.blikoon.CalculatorService"); 31 | } 32 | 33 | Widget::~Widget() 34 | { 35 | delete ui; 36 | } 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_CXX.QT_COMPILER_STDCXX = 201402L 2 | QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7 3 | QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 4 | QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 5 | QMAKE_CXX.COMPILER_MACROS = \ 6 | QT_COMPILER_STDCXX \ 7 | QMAKE_GCC_MAJOR_VERSION \ 8 | QMAKE_GCC_MINOR_VERSION \ 9 | QMAKE_GCC_PATCH_VERSION 10 | QMAKE_CXX.INCDIRS = \ 11 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++ \ 12 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/x86_64-w64-mingw32 \ 13 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/backward \ 14 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include \ 15 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed \ 16 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/include 17 | QMAKE_CXX.LIBDIRS = \ 18 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0 \ 19 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc \ 20 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/lib \ 21 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib 22 | -------------------------------------------------------------------------------- /8.Dbus/2-signals_slots/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_CXX.QT_COMPILER_STDCXX = 201402L 2 | QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7 3 | QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 4 | QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 5 | QMAKE_CXX.COMPILER_MACROS = \ 6 | QT_COMPILER_STDCXX \ 7 | QMAKE_GCC_MAJOR_VERSION \ 8 | QMAKE_GCC_MINOR_VERSION \ 9 | QMAKE_GCC_PATCH_VERSION 10 | QMAKE_CXX.INCDIRS = \ 11 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++ \ 12 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/x86_64-w64-mingw32 \ 13 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/backward \ 14 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include \ 15 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed \ 16 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/include 17 | QMAKE_CXX.LIBDIRS = \ 18 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0 \ 19 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc \ 20 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/lib \ 21 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib 22 | -------------------------------------------------------------------------------- /8.Dbus/3-DbusMessages/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_CXX.QT_COMPILER_STDCXX = 201402L 2 | QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7 3 | QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 4 | QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 5 | QMAKE_CXX.COMPILER_MACROS = \ 6 | QT_COMPILER_STDCXX \ 7 | QMAKE_GCC_MAJOR_VERSION \ 8 | QMAKE_GCC_MINOR_VERSION \ 9 | QMAKE_GCC_PATCH_VERSION 10 | QMAKE_CXX.INCDIRS = \ 11 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++ \ 12 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/x86_64-w64-mingw32 \ 13 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/backward \ 14 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include \ 15 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed \ 16 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/include 17 | QMAKE_CXX.LIBDIRS = \ 18 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0 \ 19 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc \ 20 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/lib \ 21 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib 22 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_CXX.QT_COMPILER_STDCXX = 201402L 2 | QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7 3 | QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 4 | QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 5 | QMAKE_CXX.COMPILER_MACROS = \ 6 | QT_COMPILER_STDCXX \ 7 | QMAKE_GCC_MAJOR_VERSION \ 8 | QMAKE_GCC_MINOR_VERSION \ 9 | QMAKE_GCC_PATCH_VERSION 10 | QMAKE_CXX.INCDIRS = \ 11 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++ \ 12 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/x86_64-w64-mingw32 \ 13 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/backward \ 14 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include \ 15 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed \ 16 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/include 17 | QMAKE_CXX.LIBDIRS = \ 18 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0 \ 19 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc \ 20 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/lib \ 21 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib 22 | -------------------------------------------------------------------------------- /3.ThreadSynchronization/3-6SynchronizationWaitConditions/producer.cpp: -------------------------------------------------------------------------------- 1 | #include "producer.h" 2 | #include 3 | 4 | Producer::Producer(char * buffer, int bufferSize, 5 | int * usedSlots, int totalData, 6 | QMutex * mutex, 7 | QWaitCondition * bufferFull,QWaitCondition * bufferEmpty, 8 | QObject *parent) : QThread(parent), 9 | m_buffer(buffer), m_buffer_size(bufferSize), 10 | m_used_slots(usedSlots),m_total_data(totalData), 11 | m_mutex(mutex), 12 | m_buffer_full(bufferFull), 13 | m_buffer_empty(bufferEmpty) 14 | { 15 | 16 | } 17 | 18 | void Producer::run() { 19 | 20 | 21 | for (int i = 0; i < m_total_data; ++i) { 22 | m_mutex->lock(); 23 | 24 | if((*m_used_slots) == m_buffer_size){ 25 | m_buffer_full->wait(m_mutex); 26 | } 27 | m_mutex->unlock(); 28 | 29 | //Write data to the buffer 30 | m_buffer[i % m_buffer_size] = "BACK"[QRandomGenerator::global()->bounded(4)]; 31 | 32 | m_mutex->lock(); 33 | ++(*m_used_slots); 34 | m_buffer_empty->wakeAll(); 35 | m_mutex->unlock(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/build-clientserver-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_CXX.QT_COMPILER_STDCXX = 201402L 2 | QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7 3 | QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 4 | QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 5 | QMAKE_CXX.COMPILER_MACROS = \ 6 | QT_COMPILER_STDCXX \ 7 | QMAKE_GCC_MAJOR_VERSION \ 8 | QMAKE_GCC_MINOR_VERSION \ 9 | QMAKE_GCC_PATCH_VERSION 10 | QMAKE_CXX.INCDIRS = \ 11 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++ \ 12 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/x86_64-w64-mingw32 \ 13 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/backward \ 14 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include \ 15 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed \ 16 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/include 17 | QMAKE_CXX.LIBDIRS = \ 18 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0 \ 19 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc \ 20 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/lib \ 21 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib 22 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Client-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_CXX.QT_COMPILER_STDCXX = 201402L 2 | QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7 3 | QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 4 | QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 5 | QMAKE_CXX.COMPILER_MACROS = \ 6 | QT_COMPILER_STDCXX \ 7 | QMAKE_GCC_MAJOR_VERSION \ 8 | QMAKE_GCC_MINOR_VERSION \ 9 | QMAKE_GCC_PATCH_VERSION 10 | QMAKE_CXX.INCDIRS = \ 11 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++ \ 12 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/x86_64-w64-mingw32 \ 13 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/backward \ 14 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include \ 15 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed \ 16 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/include 17 | QMAKE_CXX.LIBDIRS = \ 18 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0 \ 19 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc \ 20 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/lib \ 21 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib 22 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/build-Server-Desktop_Qt_5_12_3_MinGW_64_bit-Debug/.qmake.stash: -------------------------------------------------------------------------------- 1 | QMAKE_CXX.QT_COMPILER_STDCXX = 201402L 2 | QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 7 3 | QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 3 4 | QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0 5 | QMAKE_CXX.COMPILER_MACROS = \ 6 | QT_COMPILER_STDCXX \ 7 | QMAKE_GCC_MAJOR_VERSION \ 8 | QMAKE_GCC_MINOR_VERSION \ 9 | QMAKE_GCC_PATCH_VERSION 10 | QMAKE_CXX.INCDIRS = \ 11 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++ \ 12 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/x86_64-w64-mingw32 \ 13 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/backward \ 14 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include \ 15 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed \ 16 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/include 17 | QMAKE_CXX.LIBDIRS = \ 18 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0 \ 19 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib/gcc \ 20 | C:/Qt/Qt5.12.3/Tools/mingw730_64/x86_64-w64-mingw32/lib \ 21 | C:/Qt/Qt5.12.3/Tools/mingw730_64/lib 22 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-2ThreadPoolFeedback/worker.cpp: -------------------------------------------------------------------------------- 1 | #include "worker.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "progressevent.h" 8 | 9 | Worker::Worker(QObject * receiver) : m_receiver(receiver) 10 | { 11 | qDebug() << "Worker constructor running in thread : " << QThread::currentThread(); 12 | } 13 | 14 | Worker::~Worker(){ 15 | qDebug() << "Worker destructor running in thread : " << QThread::currentThread(); 16 | 17 | } 18 | 19 | void Worker::run() 20 | { 21 | qDebug() << "Worker run method running in thread : " << QThread::currentThread(); 22 | 23 | for(int i{0} ; i < 1000000001 ; i++){ 24 | 25 | if((i%100000) == 0){ 26 | 27 | double percentage = ((i/1000000000.0)) * 100; 28 | // qDebug() << "Current percentage : " << percentage; 29 | 30 | /* 31 | QApplication::postEvent(m_receiver, 32 | new ProgessEvent(QVariant::fromValue(percentage).toInt())); 33 | 34 | */ 35 | QMetaObject::invokeMethod(m_receiver,"gotUpdate", 36 | Qt::QueuedConnection, 37 | Q_ARG(int,QVariant::fromValue(percentage).toInt())); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /7.IPC/7-3TcpServer/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include 5 | 6 | Widget::Widget(QWidget *parent) : 7 | QWidget(parent), 8 | ui(new Ui::Widget) 9 | { 10 | ui->setupUi(this); 11 | setWindowTitle("Server| Data receiver"); 12 | 13 | m_socket = nullptr; 14 | 15 | 16 | m_server.listen(QHostAddress::LocalHost, 4040); 17 | connect(&m_server,&QTcpServer::newConnection,this,&Widget::gotConnection); 18 | 19 | } 20 | 21 | Widget::~Widget() 22 | { 23 | 24 | if (m_socket) { 25 | qDebug() << "Closing socket :" << (m_socket==nullptr); 26 | m_socket->close(); 27 | m_socket->deleteLater(); 28 | } 29 | m_server.close(); 30 | delete ui; 31 | } 32 | 33 | void Widget::gotConnection() 34 | { 35 | qDebug() << "Server got new connection"; 36 | m_socket = m_server.nextPendingConnection(); 37 | connect(m_socket,&QTcpSocket::readyRead,this,&Widget::readData); 38 | 39 | } 40 | 41 | void Widget::readData() 42 | { 43 | QDataStream in(m_socket); 44 | 45 | in.startTransaction(); 46 | 47 | 48 | QString rcvString; 49 | in >> rcvString; 50 | 51 | if(!in.commitTransaction()){ 52 | return; //Wait for more data 53 | } 54 | 55 | ui->textEdit->append(rcvString); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-2AsyncMoveToThread/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 87 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Start 23 | 24 | 25 | 26 | 27 | 28 | 29 | Stop 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Info 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-3AsyncSubclassQThread/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 87 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Start 23 | 24 | 25 | 26 | 27 | 28 | 29 | Stop 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Info 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-2ThreadPoolFeedback/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 82 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Start 23 | 24 | 25 | 26 | 27 | 28 | 29 | Info 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 24 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-6-3ThreadPoolAsync/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 82 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Start 23 | 24 | 25 | 26 | 27 | 28 | 29 | Info 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 24 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /6.QProcess/6-1QProcess/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include 5 | 6 | Widget::Widget(QWidget *parent) : 7 | QWidget(parent), 8 | ui(new Ui::Widget) 9 | { 10 | ui->setupUi(this); 11 | 12 | mProcess = new QProcess(this); 13 | 14 | connect(mProcess,&QProcess::started,[](){ 15 | qDebug() << "Process started"; 16 | 17 | }); 18 | } 19 | 20 | Widget::~Widget() 21 | { 22 | delete ui; 23 | } 24 | 25 | void Widget::on_chooseButton_clicked() 26 | { 27 | processPath = QFileDialog::getOpenFileName(this, tr("Open File"), 28 | "/home", 29 | tr("Programs (*.exe )")); 30 | if(!processPath.isNull()){ 31 | ui->processPathLineEdit->setText(processPath); 32 | } 33 | 34 | 35 | } 36 | 37 | void Widget::on_startButton_clicked() 38 | { 39 | if(!processPath.isNull()){ 40 | mProcess->start(processPath); 41 | } 42 | } 43 | 44 | void Widget::on_stopButton_clicked() 45 | { 46 | mProcess->close(); 47 | } 48 | 49 | void Widget::finished(int exitCode, QProcess::ExitStatus exitStatus) 50 | { 51 | qDebug() << "Process finished, exit code : " << exitCode ; 52 | 53 | qDebug() << "Process finished, exit status : " << exitStatus ; 54 | } 55 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/Client/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | 5 | 6 | Widget::Widget(QWidget *parent) : 7 | QWidget(parent), 8 | ui(new Ui::Widget) 9 | { 10 | ui->setupUi(this); 11 | 12 | 13 | calculatorHandle = new com::blikoon::CalculatorInterface("com.blikoon.CalculatorService", 14 | "/CalcServicePath", 15 | QDBusConnection::sessionBus()); 16 | } 17 | 18 | Widget::~Widget() 19 | { 20 | delete ui; 21 | } 22 | 23 | 24 | 25 | void Widget::on_multiplyButton_clicked() 26 | { 27 | if(calculatorHandle->isValid()){ 28 | double result = calculatorHandle->multiply(ui->number1SpinBox->value(),ui->number2SpinBox->value()); 29 | ui->resultLineEdit->setText(QString::number(result)); 30 | }else{ 31 | qCritical() << "Calculator Interface is not valid"; 32 | } 33 | 34 | } 35 | 36 | void Widget::on_divideButton_clicked() 37 | { 38 | if(calculatorHandle->isValid()){ 39 | double result = calculatorHandle->divide(ui->number1SpinBox->value(),ui->number2SpinBox->value()); 40 | ui->resultLineEdit->setText(QString::number(result)); 41 | }else{ 42 | qCritical() << "Calculator Interface is not valid"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-2ConcurrentRunSync/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include 5 | #include 6 | 7 | Widget::Widget(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::Widget) 10 | { 11 | ui->setupUi(this); 12 | qDebug() << "Ui thread : " << QThread::currentThread(); 13 | } 14 | 15 | Widget::~Widget() 16 | { 17 | delete ui; 18 | } 19 | 20 | void Widget::heavyWork() 21 | { 22 | 23 | qDebug() << "Heavy work running in thread : " << QThread::currentThread(); 24 | for(int i{0} ; i < 1000000001 ; i++){ 25 | 26 | if((i%100000) == 0){ 27 | 28 | double percentage = ((i/1000000000.0)) * 100; 29 | qDebug() << "Percentage : " << QVariant::fromValue(percentage).toInt() 30 | << " | Thread : " << QThread::currentThread(); 31 | } 32 | } 33 | } 34 | 35 | void Widget::on_startButton_clicked() 36 | { 37 | future = QtConcurrent::run(heavyWork); 38 | 39 | future.waitForFinished(); 40 | 41 | qDebug() << "Computation done!"; 42 | } 43 | 44 | void Widget::on_cancelButton_clicked() 45 | { 46 | future.cancel(); 47 | } 48 | 49 | void Widget::on_pauseButton_clicked() 50 | { 51 | future.pause(); 52 | } 53 | 54 | void Widget::on_resumeButton_clicked() 55 | { 56 | future.resume(); 57 | } 58 | -------------------------------------------------------------------------------- /6.QProcess/6-1QProcess/6-1QProcess.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-30T06:19:39 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = 6-1QProcess 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | widget.cpp 30 | 31 | HEADERS += \ 32 | widget.h 33 | 34 | FORMS += \ 35 | widget.ui 36 | 37 | # Default rules for deployment. 38 | qnx: target.path = /tmp/$${TARGET}/bin 39 | else: unix:!android: target.path = /opt/$${TARGET}/bin 40 | !isEmpty(target.path): INSTALLS += target 41 | -------------------------------------------------------------------------------- /7.IPC/7-2SharedMemory/7-2SharedMemory.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-30T08:21:07 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = 7-2SharedMemory 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | widget.cpp 30 | 31 | HEADERS += \ 32 | widget.h 33 | 34 | FORMS += \ 35 | widget.ui 36 | 37 | # Default rules for deployment. 38 | qnx: target.path = /tmp/$${TARGET}/bin 39 | else: unix:!android: target.path = /opt/$${TARGET}/bin 40 | !isEmpty(target.path): INSTALLS += target 41 | -------------------------------------------------------------------------------- /7.IPC/7-3TcpClient/7-3TcpClient.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-30T09:32:40 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui network 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = 7-3TcpClient 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | widget.cpp 30 | 31 | HEADERS += \ 32 | widget.h 33 | 34 | FORMS += \ 35 | widget.ui 36 | 37 | # Default rules for deployment. 38 | qnx: target.path = /tmp/$${TARGET}/bin 39 | else: unix:!android: target.path = /opt/$${TARGET}/bin 40 | !isEmpty(target.path): INSTALLS += target 41 | -------------------------------------------------------------------------------- /7.IPC/7-3TcpServer/7-3TcpServer.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-30T09:16:22 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui network 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = 7-3TcpServer 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | widget.cpp 30 | 31 | HEADERS += \ 32 | widget.h 33 | 34 | FORMS += \ 35 | widget.ui 36 | 37 | # Default rules for deployment. 38 | qnx: target.path = /tmp/$${TARGET}/bin 39 | else: unix:!android: target.path = /opt/$${TARGET}/bin 40 | !isEmpty(target.path): INSTALLS += target 41 | -------------------------------------------------------------------------------- /7.IPC/7-4FileConsumer/7-4FileConsumer.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-30T10:28:40 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = 7-4FileConsumer 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | widget.cpp 30 | 31 | HEADERS += \ 32 | widget.h 33 | 34 | FORMS += \ 35 | widget.ui 36 | 37 | # Default rules for deployment. 38 | qnx: target.path = /tmp/$${TARGET}/bin 39 | else: unix:!android: target.path = /opt/$${TARGET}/bin 40 | !isEmpty(target.path): INSTALLS += target 41 | -------------------------------------------------------------------------------- /7.IPC/7-4FileProducer/7-4FileProducer.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-30T10:40:16 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = 7-4FileProducer 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | widget.cpp 30 | 31 | HEADERS += \ 32 | widget.h 33 | 34 | FORMS += \ 35 | widget.ui 36 | 37 | # Default rules for deployment. 38 | qnx: target.path = /tmp/$${TARGET}/bin 39 | else: unix:!android: target.path = /opt/$${TARGET}/bin 40 | !isEmpty(target.path): INSTALLS += target 41 | -------------------------------------------------------------------------------- /8.Dbus/4-DBusInterface/Client/Client.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-09T10:58:21 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += dbus core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = Client 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | widget.cpp 30 | 31 | HEADERS += \ 32 | widget.h 33 | 34 | FORMS += \ 35 | widget.ui 36 | 37 | # Default rules for deployment. 38 | qnx: target.path = /tmp/$${TARGET}/bin 39 | else: unix:!android: target.path = /opt/$${TARGET}/bin 40 | !isEmpty(target.path): INSTALLS += target 41 | 42 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-2QThreadCreate/2-2QThreadCreate.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-25T05:26:57 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = 2-2QThreadCreate 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++17 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | widget.cpp 30 | 31 | HEADERS += \ 32 | widget.h 33 | 34 | FORMS += \ 35 | widget.ui 36 | 37 | # Default rules for deployment. 38 | qnx: target.path = /tmp/$${TARGET}/bin 39 | else: unix:!android: target.path = /opt/$${TARGET}/bin 40 | !isEmpty(target.path): INSTALLS += target 41 | -------------------------------------------------------------------------------- /2.CreatingThreads/2-5-1AsyncQThreadCreate/2-5-1AsyncQThreadCreate.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-25T10:28:38 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = 2-5-1AsyncQThreadCreate 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | widget.cpp 30 | 31 | HEADERS += \ 32 | widget.h 33 | 34 | FORMS += \ 35 | widget.ui 36 | 37 | # Default rules for deployment. 38 | qnx: target.path = /tmp/$${TARGET}/bin 39 | else: unix:!android: target.path = /opt/$${TARGET}/bin 40 | !isEmpty(target.path): INSTALLS += target 41 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-4ConcurrentMap/5-4ConcurrentMap.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-29T06:27:02 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | QT += concurrent 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 11 | 12 | TARGET = 5-4ConcurrentMap 13 | TEMPLATE = app 14 | 15 | # The following define makes your compiler emit warnings if you use 16 | # any feature of Qt which has been marked as deprecated (the exact warnings 17 | # depend on your compiler). Please consult the documentation of the 18 | # deprecated API in order to know how to port your code away from it. 19 | DEFINES += QT_DEPRECATED_WARNINGS 20 | 21 | # You can also make your code fail to compile if you use deprecated APIs. 22 | # In order to do so, uncomment the following line. 23 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 24 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 25 | 26 | CONFIG += c++11 27 | 28 | SOURCES += \ 29 | main.cpp \ 30 | widget.cpp 31 | 32 | HEADERS += \ 33 | widget.h 34 | 35 | FORMS += \ 36 | widget.ui 37 | 38 | # Default rules for deployment. 39 | qnx: target.path = /tmp/$${TARGET}/bin 40 | else: unix:!android: target.path = /opt/$${TARGET}/bin 41 | !isEmpty(target.path): INSTALLS += target 42 | -------------------------------------------------------------------------------- /8.Dbus/1.clientServer/clientserver/Client/widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This example is the client side of our example of dbus, exposing 3 | * a calculator in the server part and using it in the client. 4 | * 5 | * . The client uses the interface exposed from the server to call 6 | * stuff on the server object. 7 | * 8 | * . Interface class is generated from xml interface descriptor file, 9 | * see info in comments in server widget.h. 10 | * 11 | * 12 | * . We instantiate the interface in the constructor and give it clear 13 | * information on the , service, path and dbus connection. 14 | * 15 | * . For the rest, make sure you just explain the concepts of dbus in 16 | * the slides you're going to put together. 17 | * 18 | * */ 19 | 20 | #ifndef WIDGET_H 21 | #define WIDGET_H 22 | 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class Widget; 28 | } 29 | 30 | class Widget : public QWidget 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit Widget(QWidget *parent = nullptr); 36 | ~Widget(); 37 | 38 | 39 | 40 | private slots: 41 | void on_multiplyButton_clicked(); 42 | 43 | void on_divideButton_clicked(); 44 | 45 | private: 46 | Ui::Widget *ui; 47 | com::blikoon::CalculatorInterface * calculatorHandle; 48 | }; 49 | 50 | #endif // WIDGET_H 51 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-5ConcurrentMapped/5-5ConcurrentMapped.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-29T06:50:38 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | QT += concurrent 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 11 | 12 | TARGET = 5-5ConcurrentMapped 13 | TEMPLATE = app 14 | 15 | # The following define makes your compiler emit warnings if you use 16 | # any feature of Qt which has been marked as deprecated (the exact warnings 17 | # depend on your compiler). Please consult the documentation of the 18 | # deprecated API in order to know how to port your code away from it. 19 | DEFINES += QT_DEPRECATED_WARNINGS 20 | 21 | # You can also make your code fail to compile if you use deprecated APIs. 22 | # In order to do so, uncomment the following line. 23 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 24 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 25 | 26 | CONFIG += c++11 27 | 28 | SOURCES += \ 29 | main.cpp \ 30 | widget.cpp 31 | 32 | HEADERS += \ 33 | widget.h 34 | 35 | FORMS += \ 36 | widget.ui 37 | 38 | # Default rules for deployment. 39 | qnx: target.path = /tmp/$${TARGET}/bin 40 | else: unix:!android: target.path = /opt/$${TARGET}/bin 41 | !isEmpty(target.path): INSTALLS += target 42 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-7CuncurrentFilter/5-7CuncurrentFilter.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-29T09:50:04 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | QT += concurrent 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 11 | 12 | TARGET = 5-7CuncurrentFilter 13 | TEMPLATE = app 14 | 15 | # The following define makes your compiler emit warnings if you use 16 | # any feature of Qt which has been marked as deprecated (the exact warnings 17 | # depend on your compiler). Please consult the documentation of the 18 | # deprecated API in order to know how to port your code away from it. 19 | DEFINES += QT_DEPRECATED_WARNINGS 20 | 21 | # You can also make your code fail to compile if you use deprecated APIs. 22 | # In order to do so, uncomment the following line. 23 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 24 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 25 | 26 | CONFIG += c++11 27 | 28 | SOURCES += \ 29 | main.cpp \ 30 | widget.cpp 31 | 32 | HEADERS += \ 33 | widget.h 34 | 35 | FORMS += \ 36 | widget.ui 37 | 38 | # Default rules for deployment. 39 | qnx: target.path = /tmp/$${TARGET}/bin 40 | else: unix:!android: target.path = /opt/$${TARGET}/bin 41 | !isEmpty(target.path): INSTALLS += target 42 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-2ConcurrentRunSync/5-2ConcurrentRunSync.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-29T05:13:48 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | QT += concurrent 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 11 | 12 | TARGET = 5-2ConcurrentRunSync 13 | TEMPLATE = app 14 | 15 | # The following define makes your compiler emit warnings if you use 16 | # any feature of Qt which has been marked as deprecated (the exact warnings 17 | # depend on your compiler). Please consult the documentation of the 18 | # deprecated API in order to know how to port your code away from it. 19 | DEFINES += QT_DEPRECATED_WARNINGS 20 | 21 | # You can also make your code fail to compile if you use deprecated APIs. 22 | # In order to do so, uncomment the following line. 23 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 24 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 25 | 26 | CONFIG += c++11 27 | 28 | SOURCES += \ 29 | main.cpp \ 30 | widget.cpp 31 | 32 | HEADERS += \ 33 | widget.h 34 | 35 | FORMS += \ 36 | widget.ui 37 | 38 | # Default rules for deployment. 39 | qnx: target.path = /tmp/$${TARGET}/bin 40 | else: unix:!android: target.path = /opt/$${TARGET}/bin 41 | !isEmpty(target.path): INSTALLS += target 42 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-3ConcurrentRunAsyc/5-3ConcurrentRunAsyc.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-29T05:40:25 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | QT += concurrent 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 11 | 12 | TARGET = 5-3ConcurrentRunAsyc 13 | TEMPLATE = app 14 | 15 | # The following define makes your compiler emit warnings if you use 16 | # any feature of Qt which has been marked as deprecated (the exact warnings 17 | # depend on your compiler). Please consult the documentation of the 18 | # deprecated API in order to know how to port your code away from it. 19 | DEFINES += QT_DEPRECATED_WARNINGS 20 | 21 | # You can also make your code fail to compile if you use deprecated APIs. 22 | # In order to do so, uncomment the following line. 23 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 24 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 25 | 26 | CONFIG += c++11 27 | 28 | SOURCES += \ 29 | main.cpp \ 30 | widget.cpp 31 | 32 | HEADERS += \ 33 | widget.h 34 | 35 | FORMS += \ 36 | widget.ui 37 | 38 | # Default rules for deployment. 39 | qnx: target.path = /tmp/$${TARGET}/bin 40 | else: unix:!android: target.path = /opt/$${TARGET}/bin 41 | !isEmpty(target.path): INSTALLS += target 42 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-8ConcurrentFiltered/5-8ConcurrentFiltered.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-29T10:18:56 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | QT += concurrent 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 11 | 12 | TARGET = 5-8ConcurrentFiltered 13 | TEMPLATE = app 14 | 15 | # The following define makes your compiler emit warnings if you use 16 | # any feature of Qt which has been marked as deprecated (the exact warnings 17 | # depend on your compiler). Please consult the documentation of the 18 | # deprecated API in order to know how to port your code away from it. 19 | DEFINES += QT_DEPRECATED_WARNINGS 20 | 21 | # You can also make your code fail to compile if you use deprecated APIs. 22 | # In order to do so, uncomment the following line. 23 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 24 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 25 | 26 | CONFIG += c++11 27 | 28 | SOURCES += \ 29 | main.cpp \ 30 | widget.cpp 31 | 32 | HEADERS += \ 33 | widget.h 34 | 35 | FORMS += \ 36 | widget.ui 37 | 38 | # Default rules for deployment. 39 | qnx: target.path = /tmp/$${TARGET}/bin 40 | else: unix:!android: target.path = /opt/$${TARGET}/bin 41 | !isEmpty(target.path): INSTALLS += target 42 | -------------------------------------------------------------------------------- /5.QtConcurrent/5-10FutureSynchronizer/5-10FutureSynchronizer.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-29T10:57:38 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | QT += concurrent 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 11 | 12 | TARGET = 5-10FutureSynchronizer 13 | TEMPLATE = app 14 | 15 | # The following define makes your compiler emit warnings if you use 16 | # any feature of Qt which has been marked as deprecated (the exact warnings 17 | # depend on your compiler). Please consult the documentation of the 18 | # deprecated API in order to know how to port your code away from it. 19 | DEFINES += QT_DEPRECATED_WARNINGS 20 | 21 | # You can also make your code fail to compile if you use deprecated APIs. 22 | # In order to do so, uncomment the following line. 23 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 24 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 25 | 26 | CONFIG += c++11 27 | 28 | SOURCES += \ 29 | main.cpp \ 30 | widget.cpp 31 | 32 | HEADERS += \ 33 | widget.h 34 | 35 | FORMS += \ 36 | widget.ui 37 | 38 | # Default rules for deployment. 39 | qnx: target.path = /tmp/$${TARGET}/bin 40 | else: unix:!android: target.path = /opt/$${TARGET}/bin 41 | !isEmpty(target.path): INSTALLS += target 42 | --------------------------------------------------------------------------------