diff options
Diffstat (limited to 'examples/widgets/widgets/icons')
-rw-r--r-- | examples/widgets/widgets/icons/.prev_CMakeLists.txt | 39 | ||||
-rw-r--r-- | examples/widgets/widgets/icons/CMakeLists.txt | 39 | ||||
-rw-r--r-- | examples/widgets/widgets/icons/imagedelegate.cpp | 2 | ||||
-rw-r--r-- | examples/widgets/widgets/icons/main.cpp | 6 | ||||
-rw-r--r-- | examples/widgets/widgets/icons/mainwindow.cpp | 24 | ||||
-rw-r--r-- | examples/widgets/widgets/icons/mainwindow.h | 4 |
6 files changed, 89 insertions, 25 deletions
diff --git a/examples/widgets/widgets/icons/.prev_CMakeLists.txt b/examples/widgets/widgets/icons/.prev_CMakeLists.txt new file mode 100644 index 0000000000..01cc94abdb --- /dev/null +++ b/examples/widgets/widgets/icons/.prev_CMakeLists.txt @@ -0,0 +1,39 @@ +# Generated from icons.pro. + +cmake_minimum_required(VERSION 3.14) +project(icons LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(INSTALL_EXAMPLEDIR "examples/widgets/widgets/icons") + +find_package(Qt6 COMPONENTS Core) +find_package(Qt6 COMPONENTS Gui) +find_package(Qt6 COMPONENTS Widgets) + +add_qt_gui_executable(icons + iconpreviewarea.cpp iconpreviewarea.h + iconsizespinbox.cpp iconsizespinbox.h + imagedelegate.cpp imagedelegate.h + main.cpp + mainwindow.cpp mainwindow.h +) +target_compile_definitions(icons PUBLIC + SRCDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/\\\" +) + +target_link_libraries(icons PUBLIC + Qt::Core + Qt::Gui + Qt::Widgets +) + +install(TARGETS icons + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/widgets/widgets/icons/CMakeLists.txt b/examples/widgets/widgets/icons/CMakeLists.txt new file mode 100644 index 0000000000..f154c534f9 --- /dev/null +++ b/examples/widgets/widgets/icons/CMakeLists.txt @@ -0,0 +1,39 @@ +# Generated from icons.pro. + +cmake_minimum_required(VERSION 3.14) +project(icons LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(INSTALL_EXAMPLEDIR "examples/widgets/widgets/icons") + +find_package(Qt6 COMPONENTS Core) +find_package(Qt6 COMPONENTS Gui) +find_package(Qt6 COMPONENTS Widgets) + +add_qt_gui_executable(icons + iconpreviewarea.cpp iconpreviewarea.h + iconsizespinbox.cpp iconsizespinbox.h + imagedelegate.cpp imagedelegate.h + main.cpp + mainwindow.cpp mainwindow.h +) +target_compile_definitions(icons PUBLIC + SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}" # special case +) + +target_link_libraries(icons PUBLIC + Qt::Core + Qt::Gui + Qt::Widgets +) + +install(TARGETS icons + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/widgets/widgets/icons/imagedelegate.cpp b/examples/widgets/widgets/icons/imagedelegate.cpp index 4fd251aa1b..9f1e19c9eb 100644 --- a/examples/widgets/widgets/icons/imagedelegate.cpp +++ b/examples/widgets/widgets/icons/imagedelegate.cpp @@ -70,7 +70,7 @@ QWidget *ImageDelegate::createEditor(QWidget *parent, else if (index.column() == 2) comboBox->addItems(IconPreviewArea::iconStateNames()); - connect(comboBox, QOverload<int>::of(&QComboBox::activated), + connect(comboBox, &QComboBox::activated, this, &ImageDelegate::emitCommitData); return comboBox; diff --git a/examples/widgets/widgets/icons/main.cpp b/examples/widgets/widgets/icons/main.cpp index 632795c18c..aff2d2013e 100644 --- a/examples/widgets/widgets/icons/main.cpp +++ b/examples/widgets/widgets/icons/main.cpp @@ -64,15 +64,9 @@ int main(int argc, char *argv[]) commandLineParser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); commandLineParser.addHelpOption(); commandLineParser.addVersionOption(); - QCommandLineOption noHighDpiPixmapOption("no-highdpi-pixmaps", - "Disable High DPI image loading (Qt::AA_UseHighDpiPixmaps)"); - commandLineParser.addOption(noHighDpiPixmapOption); commandLineParser.addPositionalArgument(MainWindow::tr("[file]"), MainWindow::tr("Icon file(s) to open.")); commandLineParser.process(QCoreApplication::arguments()); - if (!commandLineParser.isSet(noHighDpiPixmapOption)) - QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); - MainWindow mainWin; if (!commandLineParser.positionalArguments().isEmpty()) mainWin.loadImages(commandLineParser.positionalArguments()); diff --git a/examples/widgets/widgets/icons/mainwindow.cpp b/examples/widgets/widgets/icons/mainwindow.cpp index 4f990f7320..bd14bff518 100644 --- a/examples/widgets/widgets/icons/mainwindow.cpp +++ b/examples/widgets/widgets/icons/mainwindow.cpp @@ -53,6 +53,7 @@ #include "iconsizespinbox.h" #include "imagedelegate.h" +#include <QActionGroup> #include <QApplication> #include <QButtonGroup> #include <QCheckBox> @@ -172,15 +173,16 @@ void MainWindow::changeStyle(bool checked) //! [4] //! [5] -void MainWindow::changeSize(int id, bool checked) +void MainWindow::changeSize(QAbstractButton *button, bool checked) { if (!checked) return; - const bool other = id == int(OtherSize); + const int index = sizeButtonGroup->id(button); + const bool other = index == int(OtherSize); const int extent = other ? otherSpinBox->value() - : QApplication::style()->pixelMetric(static_cast<QStyle::PixelMetric>(id)); + : QApplication::style()->pixelMetric(static_cast<QStyle::PixelMetric>(index)); previewArea->setSize(QSize(extent, extent)); otherSpinBox->setEnabled(other); @@ -188,7 +190,7 @@ void MainWindow::changeSize(int id, bool checked) void MainWindow::triggerChangeSize() { - changeSize(sizeButtonGroup->checkedId(), true); + changeSize(sizeButtonGroup->checkedButton(), true); } //! [5] @@ -318,12 +320,6 @@ void MainWindow::loadImages(const QStringList &fileNames) } } -void MainWindow::useHighDpiPixmapsChanged(int checkState) -{ - QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, checkState == Qt::Checked); - changeIcon(); -} - //! [20] void MainWindow::removeAllImages() { @@ -372,7 +368,7 @@ QWidget *MainWindow::createIconSizeGroupBox() sizeButtonGroup = new QButtonGroup(this); sizeButtonGroup->setExclusive(true); - connect(sizeButtonGroup, QOverload<int, bool>::of(&QButtonGroup::buttonToggled), + connect(sizeButtonGroup, &QButtonGroup::buttonToggled, this, &MainWindow::changeSize); QRadioButton *smallRadioButton = new QRadioButton; @@ -400,7 +396,7 @@ QWidget *MainWindow::createIconSizeGroupBox() //! [26] //! [27] - connect(otherSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), + connect(otherSpinBox, &QSpinBox::valueChanged, this, &MainWindow::triggerChangeSize); QHBoxLayout *otherSizeLayout = new QHBoxLayout; @@ -442,10 +438,6 @@ QWidget *MainWindow::createHighDpiIconSizeGroupBox() screenNameLabel = new QLabel(highDpiGroupBox); layout->addRow(tr("Screen:"), screenNameLabel); layout->addRow(tr("Device pixel ratio:"), devicePixelRatioLabel); - QCheckBox *highDpiPixmapsCheckBox = new QCheckBox(QLatin1String("Qt::AA_UseHighDpiPixmaps")); - highDpiPixmapsCheckBox->setChecked(QCoreApplication::testAttribute(Qt::AA_UseHighDpiPixmaps)); - connect(highDpiPixmapsCheckBox, &QCheckBox::stateChanged, this, &MainWindow::useHighDpiPixmapsChanged); - layout->addRow(highDpiPixmapsCheckBox); return highDpiGroupBox; } diff --git a/examples/widgets/widgets/icons/mainwindow.h b/examples/widgets/widgets/icons/mainwindow.h index c67d828cab..cd77dae8e8 100644 --- a/examples/widgets/widgets/icons/mainwindow.h +++ b/examples/widgets/widgets/icons/mainwindow.h @@ -62,6 +62,7 @@ class QActionGroup; class QLabel; class QButtonGroup; class QTableWidget; +class QAbstractButton; QT_END_NAMESPACE class IconPreviewArea; class IconSizeSpinBox; @@ -81,13 +82,12 @@ public: private slots: void about(); void changeStyle(bool checked); - void changeSize(int, bool); + void changeSize(QAbstractButton *button, bool); void triggerChangeSize(); void changeIcon(); void addSampleImages(); void addOtherImages(); void removeAllImages(); - void useHighDpiPixmapsChanged(int checkState); void screenChanged(); private: |