From 110b78859da6cf7b4d5021f5fed7461932acb670 Mon Sep 17 00:00:00 2001 From: "andrei.malashkin" Date: Wed, 16 Jun 2021 13:33:35 +0200 Subject: [PATCH 1/2] test qt components --- recipes/qt/5.x.x/test_package/CMakeLists.txt | 4 +- recipes/qt/5.x.x/test_package/meson.build | 2 +- .../qt/5.x.x/test_package/test_package.cpp | 39 +++++++++++++++++-- .../qt/5.x.x/test_package/test_package.pro | 2 +- 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/recipes/qt/5.x.x/test_package/CMakeLists.txt b/recipes/qt/5.x.x/test_package/CMakeLists.txt index 5f0647c685c50..f24a7341d4c1e 100644 --- a/recipes/qt/5.x.x/test_package/CMakeLists.txt +++ b/recipes/qt/5.x.x/test_package/CMakeLists.txt @@ -9,7 +9,7 @@ conan_set_vs_runtime() conan_set_libcxx() conan_output_dirs_setup() -find_package(Qt5 COMPONENTS Core REQUIRED CONFIG) +find_package(Qt5 COMPONENTS Core Widgets Gui Network OpenGL Concurrent REQUIRED CONFIG) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) @@ -20,4 +20,4 @@ add_executable(${PROJECT_NAME} ${SOURCES}) # Must compile with "-fPIC" since Qt was built with -reduce-relocations. target_compile_options(${PROJECT_NAME} PRIVATE -fPIC) -target_link_libraries(${PROJECT_NAME} Qt5::Core) +target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Concurrent) diff --git a/recipes/qt/5.x.x/test_package/meson.build b/recipes/qt/5.x.x/test_package/meson.build index afb1bb221b05b..82663bc1c13ea 100644 --- a/recipes/qt/5.x.x/test_package/meson.build +++ b/recipes/qt/5.x.x/test_package/meson.build @@ -1,6 +1,6 @@ project('test_package', 'cpp') qt5 = import('qt5') -qt5_dep = dependency('qt5', modules: ['Core']) +qt5_dep = dependency('qt5', modules: ['Core, Widgets, Gui, Network, OpenGL, Concurrent']) moc_files = qt5.preprocess(moc_headers : 'greeter.h', qresources : 'example.qrc') executable('test_package', 'test_package.cpp', moc_files, dependencies : qt5_dep) diff --git a/recipes/qt/5.x.x/test_package/test_package.cpp b/recipes/qt/5.x.x/test_package/test_package.cpp index ffcc7f966de93..53db8e664e024 100644 --- a/recipes/qt/5.x.x/test_package/test_package.cpp +++ b/recipes/qt/5.x.x/test_package/test_package.cpp @@ -1,14 +1,41 @@ -#include +#include #include #include #include #include "greeter.h" #include +#include +#include + +void drawPixmapFragments() +{ + QPixmap origPixmap(20, 20); + QPixmap resPixmap(20, 20); + QPainter::PixmapFragment fragments[4] = { {15, 15, 0, 0, 10, 10, 1, 1, 0, 1}, + { 5, 15, 10, 0, 10, 10, 1, 1, 0, 1}, + {15, 5, 0, 10, 10, 10, 1, 1, 0, 1}, + { 5, 5, 10, 10, 10, 10, 1, 1, 0, 1} }; + { + QPainter p(&origPixmap); + p.fillRect(0, 0, 10, 10, Qt::red); + p.fillRect(10, 0, 10, 10, Qt::green); + p.fillRect(0, 10, 10, 10, Qt::blue); + p.fillRect(10, 10, 10, 10, Qt::yellow); + } + { + QPainter p(&resPixmap); + p.drawPixmapFragments(fragments, 4, origPixmap); + } + + QImage origImage = origPixmap.toImage().convertToFormat(QImage::Format_ARGB32); + QImage resImage = resPixmap.toImage().convertToFormat(QImage::Format_ARGB32); + QPainter::PixmapFragment fragment = QPainter::PixmapFragment::create(QPointF(20, 20), QRectF(30, 30, 2, 2)); +} int main(int argc, char *argv[]){ - QCoreApplication app(argc, argv); - QCoreApplication::setApplicationName("Application Example"); - QCoreApplication::setApplicationVersion("1.0.0"); + QGuiApplication app(argc, argv); + QGuiApplication::setApplicationName("Application Example"); + QGuiApplication::setApplicationVersion("1.0.0"); QString name = argc > 0 ? argv[1] : ""; if (name.isEmpty()) { @@ -25,5 +52,9 @@ int main(int argc, char *argv[]){ qDebug() << "Resource content:" << f.readAll(); f.close(); + drawPixmapFragments(); + + QNetworkAccessManager testNetworkModule; + return app.exec(); } diff --git a/recipes/qt/5.x.x/test_package/test_package.pro b/recipes/qt/5.x.x/test_package/test_package.pro index 1024feaf820d0..754e62d425ea5 100644 --- a/recipes/qt/5.x.x/test_package/test_package.pro +++ b/recipes/qt/5.x.x/test_package/test_package.pro @@ -4,7 +4,7 @@ HEADERS += greeter.h RESOURCES = example.qrc -QT -= gui +QT += core widgets gui network concurrent CONFIG += console From 1982f81df9765d60f879e957e3b5388d1cbd6882 Mon Sep 17 00:00:00 2001 From: "andrei.malashkin" Date: Thu, 17 Jun 2021 09:48:41 +0200 Subject: [PATCH 2/2] add non-gui minimal tests --- recipes/qt/5.x.x/test_package/CMakeLists.txt | 4 +- recipes/qt/5.x.x/test_package/meson.build | 2 +- .../qt/5.x.x/test_package/test_package.cpp | 42 +++++-------------- .../qt/5.x.x/test_package/test_package.pro | 3 +- 4 files changed, 15 insertions(+), 36 deletions(-) diff --git a/recipes/qt/5.x.x/test_package/CMakeLists.txt b/recipes/qt/5.x.x/test_package/CMakeLists.txt index f24a7341d4c1e..46a126ea03cce 100644 --- a/recipes/qt/5.x.x/test_package/CMakeLists.txt +++ b/recipes/qt/5.x.x/test_package/CMakeLists.txt @@ -9,7 +9,7 @@ conan_set_vs_runtime() conan_set_libcxx() conan_output_dirs_setup() -find_package(Qt5 COMPONENTS Core Widgets Gui Network OpenGL Concurrent REQUIRED CONFIG) +find_package(Qt5 COMPONENTS Core Network Sql REQUIRED CONFIG) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) @@ -20,4 +20,4 @@ add_executable(${PROJECT_NAME} ${SOURCES}) # Must compile with "-fPIC" since Qt was built with -reduce-relocations. target_compile_options(${PROJECT_NAME} PRIVATE -fPIC) -target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Concurrent) +target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network Qt5::Sql) diff --git a/recipes/qt/5.x.x/test_package/meson.build b/recipes/qt/5.x.x/test_package/meson.build index 82663bc1c13ea..ed8b8bf9a339a 100644 --- a/recipes/qt/5.x.x/test_package/meson.build +++ b/recipes/qt/5.x.x/test_package/meson.build @@ -1,6 +1,6 @@ project('test_package', 'cpp') qt5 = import('qt5') -qt5_dep = dependency('qt5', modules: ['Core, Widgets, Gui, Network, OpenGL, Concurrent']) +qt5_dep = dependency('qt5', modules: ['Core', 'Network', 'Sql']) moc_files = qt5.preprocess(moc_headers : 'greeter.h', qresources : 'example.qrc') executable('test_package', 'test_package.cpp', moc_files, dependencies : qt5_dep) diff --git a/recipes/qt/5.x.x/test_package/test_package.cpp b/recipes/qt/5.x.x/test_package/test_package.cpp index 53db8e664e024..1aa0febbebcd7 100644 --- a/recipes/qt/5.x.x/test_package/test_package.cpp +++ b/recipes/qt/5.x.x/test_package/test_package.cpp @@ -1,41 +1,20 @@ -#include +#include #include #include #include #include "greeter.h" #include -#include -#include -void drawPixmapFragments() -{ - QPixmap origPixmap(20, 20); - QPixmap resPixmap(20, 20); - QPainter::PixmapFragment fragments[4] = { {15, 15, 0, 0, 10, 10, 1, 1, 0, 1}, - { 5, 15, 10, 0, 10, 10, 1, 1, 0, 1}, - {15, 5, 0, 10, 10, 10, 1, 1, 0, 1}, - { 5, 5, 10, 10, 10, 10, 1, 1, 0, 1} }; - { - QPainter p(&origPixmap); - p.fillRect(0, 0, 10, 10, Qt::red); - p.fillRect(10, 0, 10, 10, Qt::green); - p.fillRect(0, 10, 10, 10, Qt::blue); - p.fillRect(10, 10, 10, 10, Qt::yellow); - } - { - QPainter p(&resPixmap); - p.drawPixmapFragments(fragments, 4, origPixmap); - } +// Qt Network test +#include - QImage origImage = origPixmap.toImage().convertToFormat(QImage::Format_ARGB32); - QImage resImage = resPixmap.toImage().convertToFormat(QImage::Format_ARGB32); - QPainter::PixmapFragment fragment = QPainter::PixmapFragment::create(QPointF(20, 20), QRectF(30, 30, 2, 2)); -} +// Qt Sql test +#include int main(int argc, char *argv[]){ - QGuiApplication app(argc, argv); - QGuiApplication::setApplicationName("Application Example"); - QGuiApplication::setApplicationVersion("1.0.0"); + QCoreApplication app(argc, argv); + QCoreApplication::setApplicationName("Application Example"); + QCoreApplication::setApplicationVersion("1.0.0"); QString name = argc > 0 ? argv[1] : ""; if (name.isEmpty()) { @@ -52,9 +31,8 @@ int main(int argc, char *argv[]){ qDebug() << "Resource content:" << f.readAll(); f.close(); - drawPixmapFragments(); - - QNetworkAccessManager testNetworkModule; + QNetworkAccessManager networkTester; + QSqlDatabase sqlTester; return app.exec(); } diff --git a/recipes/qt/5.x.x/test_package/test_package.pro b/recipes/qt/5.x.x/test_package/test_package.pro index 754e62d425ea5..51c7df45aea35 100644 --- a/recipes/qt/5.x.x/test_package/test_package.pro +++ b/recipes/qt/5.x.x/test_package/test_package.pro @@ -4,7 +4,8 @@ HEADERS += greeter.h RESOURCES = example.qrc -QT += core widgets gui network concurrent +QT -= gui +QT += network sql CONFIG += console