The first step is to run PepperMill on your application and then update your build files. If your project is already using CMake this should be a quick process and pretty simple. Once these two steps are done there may be additional modifications which need to be done by hand or a few simple search and replace passes. The following notes were collated from other developers who have been through the migration.
-
Run PepperMill
-
Modifications to your CMake build files
-
change your build files to enable C++17
-
remove any lines which refer to AUTOMOC
-
replace any lines which refer to AUTOUIC with the following syntax
COPPERSPICE_RESOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/../forms/mainwindow.ui
)
-
update the call to find_package
find_package(Qt4 REQUIRED QtCore QtGui QtMultimedia QtNetwork QtSql)
find_package(CopperSpice REQUIRED)
-
update all library references in the style shown below
Prior Syntax | Replacement Syntax |
Qt4::QtCore | CopperSpice::CsCore |
Qt4::QtGui | CopperSpice::CsGui |
Qt4::QtMultimedia | CopperSpice::CsMultimedia |
Qt4::QtNetwork | CopperSpice::CsNetwork |
Qt4::QtSql | CopperSpice::CsSql |
-
list the libraries and plugins your application will require at run time
-
these calls are added in your root project
CMakeLists.txt
file
cs_copy_library(CsCore)
cs_copy_library(CsGui)
cs_copy_library(CsMultimedia)
cs_copy_library(CsNetwork)
cs_copy_library(CsOpenGL)
cs_copy_library(CsScript)
cs_copy_library(CsSql)
cs_copy_library(CsSvg)
cs_copy_library(CsXml)
cs_copy_library(CsXmlPatterns)
cs_copy_plugins(CsGui)
cs_copy_plugins(CsPrinterDriver)
cs_copy_plugins(CsMultimedia)
cs_copy_plugins(CsOpenGL)
cs_copy_plugins(CsSqlMySql)
cs_copy_plugins(CsSqlPsql)
cs_copy_plugins(CsImageFormatsSvg)
-
if your project contains a .qrc file add the following
COPPERSPICE_RESOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/src/some_file.qrc
)
-
if your project contains a .ui file add the following
COPPERSPICE_RESOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/src/mainwindow.ui
)
-
For an example refer to this project cmake build file
-
Source code changes: Strings
-
QString is a typedef for QString8
-
QString::isNull() was removed, replace with QString::isEmpty()
-
replace toAscii().constData() with toLatin1().constData()
-
replace arg() with formatArg(), refer to QStringParser
-
replace toInt() with toInteger<int>
-
QString::SplitBehavior enum moved to QStringParser
QString::KeepEmptyParts
QString::SkipEmptyParts
QStringParser::KeepEmptyParts
QStringParser::SkipEmptyParts
-
add explicit conversion to QString()
QString text = (var == Images::Continuous) ? "Continuous" : "Once";
QString text = (var == Images::Continuous) ? QString("Continuous") : QString("Once");
-
Source code changes: Languages/Locales
-
replace countriesForLanguage() with matchingLocales()
QLocale::Language langId = QLocale::German;
QList<QLocale::Country> countryList = QLocale::countriesForLanguage(langId);
for (auto country : countryList) {
QString label = QLocale::languageToString(langId) + "/" + QLocale::countryToString(country);
}
QLocale::Language langId = QLocale::German;
QList<QLocale> localeList = QLocale::matchingLocales(langId, QLocale::AnyScript, QLocale::AnyCountry);
for (auto locale : localeList) {
QString label = QLocale::languageToString(langId) + "/" + QLocale::countryToString(locale.country());
}
-
Source code changes: General
-
replace enum type QFileDialog::Options with QFileDialog::FileDialogOptions
-
replace class QRegExp with QRegularExpression
-
regular expressions
QString line = "some text";
QString str = line.section(QRegularExpression("(\\s)+"), 0, 0);
QString str = QStringParser::section(line, QRegularExpression("(\\s)+", 0, 0));
-
replacement for
foreach
and forever
foreach (x, y) {
for (x : y) {
forever {
while true() {
-
Source code changes: Enum Change
-
enum Qt::Modifier removed, use enum Qt::KeyboardModifier
Obsolete | Replace With |
Qt::ALT (or Qt::Modifier::ALT) | Qt::KeyboardModifier::AltModifier |
Qt::CTRL (or Qt::Modifier::CTRL) | Qt::KeyboardModifier::ControlModifier |
Qt::META (or Qt::Modifier::META) | Qt::KeyboardModifier::MetaModifier |
Qt::SHIFT (or Qt::Modifier::SHIFT) | Qt::KeyboardModifier::ShiftModifier |
-
Source code changes: Headers
-
CsCore header file name changes
Obsolete Header | Use these Header File Names |
#include <Qt> | #include <qnamespace.h> |
#include <qt.h> | #include <qnamespace.h> |
#include <QtNamespace> | #include <qnamespace.h> |
#include <QtAlgorithms> | #include <qalgorithms.h> |
#include <QtGlobal> | #include <qglobal.h> |
#include <QtEndian> | #include <qendian.h> |
-
CsMultimedia header file name changes
Obsolete Header | Mixed Case Header Name |
#include <QMediaServiceProviderPlugin> | #include <qmediaservice_provider_plugin.h> |
-
CsNetwork header file name changes
Obsolete Header | Mixed Case Header Name |
#include <QNetworkAccessManager> | #include <QAccess_Manager> |
| #include <QNetAccess_Manager> |
| |
#include <QAbstractNetworkCache> | #include <QAbstract_NetworkCache> |
#include <QHttpHeader> | #include <QHttp_Header> |
#include <QHttpMultiPart> | #include <QHttp_MultiPart> |
#include <QHttpPart> | #include <QHttp_Part> |
#include <QNetworkCacheMetaData> | #include <QNetwork_CacheMetaData> |
#include <QNetworkCookie> | #include <QNetwork_Cookie> |
#include <QNetworkCookieJar> | #include <QNetwork_CookieJar> |
#include <QNetworkDiskCache> | #include <QNetwork_DiskCache> |
#include <QNetworkReply> | #include <QNetwork_Reply> |
#include <QNetworkRequest> | #include <QNetwork_Request> |
#include <QSslCertificateExtension> | #include <QSslCertificate_Extension> |
-
Source code changes: QVariant
-
QVariant and QMetaType changes as of CopperSpice 1.7
-
complete redesign and refactoring of the entire QVariant system
-
QVariant uses std::variant for storing its data
-
property system returns a QVariant::Type, prior return type was QMetaType::Type
-
macro Q_DECLARE_METATYPE(Type) has been changed to CS_DECLARE_METATYPE(Type)
-
QMetaType
has been removed since it is obsolete
-
change QVariant::constData() to call QVariant::getData()
-
remove
qRegisterMetaTypeStreamOperators<T>
since it is obsolete
-
change calls to QVariant::isNull()
-
use QVariant::isValid() and invert logic
-
changes for
qVariantValue
or qvariant_cast
qVariantValue<T>(data);
qvariant_cast<T>(data);
data.value<T>();
-
change for
qMetaTypeId
-
metaType id is automatically assigned the first time it is needed
qMetaTypeId<QIODevice *>();
QVariant::typeToTypeId<QIODevice *>();
-
remove
qRegisterMetaType<T>
since it is obsolete
-
metaType id is automatically assigned the first time it is needed
-
Source code changes: QVariant constructors for GUI Enums
-
Several enum types which were implicitly convertible to a QVariant must now be explicitly constructed
Enum Types | Used in Class |
Qt::BrushStyle | QBrush |
Qt::CursorShape | QCursor |
Qt::GlobalColor | QColor |
Qt::PenStyle | QPen |
QVariant colorA = Qt::red;
QVariant colorB = QColor(Qt::red);
-
Source code changes: Signals / Slots
-
QObject::receivers() takes one QString as its argument, the SIGNAL macro expands to two strings
myObj::receivers(SIGNAL(yourSignal()));
myObj::receivers(SLOT(yourSignal()));
-
if you declared an overloaded Signal or Slot replace the CS_SIGNAL_2() or CS_SLOT_2() macro calls with
CS_SIGNAL_OVERLOAD()
or CS_SLOT_OVERLOAD()
-
for parameters passed to a method with an associated tag, modify the CS_TAG() macro parameter list
-
Source code changes: Print Settings
-
setPageMargins()
printer->setPageMargins(0.00, 0.00, 0.00, 0.00, QPageSize::Unit::Inch);
printer->setPageMargins(QMarginsF(0.00, 0.00, 0.00, 0.00), QPageSize::Unit::Inch);
-
enum value QPrinter::Inch should be QPageSize::Unit::Inch
-
enum value QPrinter::Letter should be QPageSize::PageSizeId::Letter