diff --git a/qtservice/examples/interactive/main.cpp b/qtservice/examples/interactive/main.cpp index d4858b1..5c0eacb 100644 --- a/qtservice/examples/interactive/main.cpp +++ b/qtservice/examples/interactive/main.cpp @@ -39,7 +39,11 @@ ****************************************************************************/ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include +#else +#include +#endif #include #include #include @@ -77,8 +81,12 @@ InteractiveService::~InteractiveService() void InteractiveService::start() { #if defined(Q_OS_WIN) + #if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) if ((QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) && (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)) { + #else + if(QSysInfo::productVersion().toUInt() >= 8) { + #endif logMessage( "Service GUI not allowed on Windows Vista. See the documentation for this example for more information.", QtServiceBase::Error ); return; } @@ -87,7 +95,11 @@ void InteractiveService::start() qApp->setQuitOnLastWindowClosed(false); gui = new QLabel("Service", 0, Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) gui->move(QApplication::desktop()->availableGeometry().topLeft()); +#else + gui->move(qApp->primaryScreen()->availableGeometry().topLeft()); +#endif gui->show(); } diff --git a/qtservice/examples/server/main.cpp b/qtservice/examples/server/main.cpp index ebcc218..009579e 100644 --- a/qtservice/examples/server/main.cpp +++ b/qtservice/examples/server/main.cpp @@ -46,7 +46,9 @@ #include #include #include - +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#endif #include "qtservice.h" // HttpDaemon is the the class that implements the simple HTTP server. @@ -98,7 +100,12 @@ private slots: // document back. QTcpSocket* socket = (QTcpSocket*)sender(); if (socket->canReadLine()) { - QStringList tokens = QString(socket->readLine()).split(QRegExp("[ \r\n][ \r\n]*")); + QStringList tokens; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + tokens = QString(socket->readLine()).split(QRegularExpression("[ \r\n][ \r\n]*")); +#else + tokens = QString(socket->readLine()).split(QRegExp("[ \r\n][ \r\n]*")); +#endif if (tokens[0] == "GET") { QTextStream os(socket); os.setAutoDetectUnicode(true); diff --git a/qtservice/src/qtservice.cpp b/qtservice/src/qtservice.cpp index 5eae058..3374a1e 100644 --- a/qtservice/src/qtservice.cpp +++ b/qtservice/src/qtservice.cpp @@ -663,7 +663,7 @@ QtServiceBase::QtServiceBase(int argc, char **argv, const QString &name) d_ptr = new QtServiceBasePrivate(nm); d_ptr->q_ptr = this; - d_ptr->serviceFlags = 0; + d_ptr->serviceFlags = static_cast(0); d_ptr->sysd = 0; for (int i = 0; i < argc; ++i) d_ptr->args.append(QString::fromLocal8Bit(argv[i])); diff --git a/qtservice/src/qtservice.h b/qtservice/src/qtservice.h index 01d5b07..4fb3c3c 100644 --- a/qtservice/src/qtservice.h +++ b/qtservice/src/qtservice.h @@ -59,7 +59,7 @@ # define QT_QTSERVICE_EXPORT #endif -class QStringList; +//class QStringList; class QtServiceControllerPrivate; class QT_QTSERVICE_EXPORT QtServiceController diff --git a/qtservice/src/qtservice_win.cpp b/qtservice/src/qtservice_win.cpp index e5b7ecc..3b9a1ae 100644 --- a/qtservice/src/qtservice_win.cpp +++ b/qtservice/src/qtservice_win.cpp @@ -737,10 +737,17 @@ class QtServiceAppEventFilter : public QAbstractNativeEventFilter { public: QtServiceAppEventFilter() {} - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + virtual bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result); +#else + bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; +#endif }; - +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QtServiceAppEventFilter::nativeEventFilter(const QByteArray &, void *message, qintptr *result) +#else bool QtServiceAppEventFilter::nativeEventFilter(const QByteArray &, void *message, long *result) +#endif { MSG *winMessage = (MSG*)message; if (winMessage->message == WM_ENDSESSION && (winMessage->lParam & ENDSESSION_LOGOFF)) {