From 1ae854eae2fb8dce43f262becb707a1bc932e8f8 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sat, 15 Sep 2018 13:43:37 +0200 Subject: [PATCH] Port to Qt5 This is just a straightforward port using https://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5 --- CMakeLists.txt | 12 +++++------- src/CMakeLists.txt | 9 +++------ src/MainWindow.cpp | 2 +- src/MainWindow.h | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bad5baf..104c2d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ # projects. "animbar" compiles the source and "package" creates the windows # installer. Only release builds will work on win32 because of dependancy madness. -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.1.0) project(animbar) @@ -45,12 +45,10 @@ ENDIF(MSVC) # setup qt #----------------------------------------------------------------------- -# On Ubuntu, run cmake with -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4, the -# export QT_SELECT mechanism does confuse FindQt4, e.g. -# cmake ../ -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4 -FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtXml QtSvg REQUIRED) - -INCLUDE(${QT_USE_FILE}) +# On Ubuntu, run cmake with -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt5, thes +# export QT_SELECT mechanism does confuse FindQt, e.g. +# cmake ../ -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt5 +FIND_PACKAGE(Qt5 COMPONENTS Core Widgets Xml Svg REQUIRED) #----------------------------------------------------------------------- # some all platform options diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ea31da..30fdecc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,6 @@ # # for cmake and qt see -# http://cmake.org/cmake/help/cmake2.6docs.html#module:FindQt4 -# and -# http://www.bineteri.com/qtwithcmake -# +# https://doc.qt.io/qt-5/cmake-manual.html #----------------------------------------------------------------------- # static runtime linking (is bad, but we don't want to go through the @@ -67,7 +64,7 @@ SET(animbar_MOC_HDRS ) # moc 'em -QT4_WRAP_CPP(animbar_MOC_SRCS ${animbar_MOC_HDRS}) +QT5_WRAP_CPP(animbar_MOC_SRCS ${animbar_MOC_HDRS}) #----------------------------------------------------------------------- # What makes up our final target executable. WIN32, MACOSX_BUNDLE that @@ -81,7 +78,7 @@ ADD_EXECUTABLE(animbar ) TARGET_LINK_LIBRARIES(animbar - ${QT_LIBRARIES} + Qt5::Widgets ) #----------------------------------------------------------------------- diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 7538bff..28b1be0 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -486,7 +486,7 @@ void MainWindow::openFile() /* create new list entry and add it */ QFileInfo fi(files[i]); QListWidgetItem *li = new QListWidgetItem(icon, fi.fileName(), imageList); - li->setData(Qt::UserRole, qVariantFromValue(img)); + li->setData(Qt::UserRole, QVariant::fromValue(img)); li->setFlags(li->flags() | Qt::ItemIsDragEnabled); imageList->addItem(li); } diff --git a/src/MainWindow.h b/src/MainWindow.h index 947bfee..9ed481b 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -20,7 +20,7 @@ #ifndef _MAINWINDOW_H #define _MAINWINDOW_H -#include +#include #include "animbar.h"