diff --git a/QtSLiM/QtSLiM.pro b/QtSLiM/QtSLiM.pro index 343832aa..2f9dfa68 100644 --- a/QtSLiM/QtSLiM.pro +++ b/QtSLiM/QtSLiM.pro @@ -44,8 +44,10 @@ DEFINES += GIT_SHA1=$$GIT_HASH # Warn and error on usage of deprecated Qt APIs; see also -Wno-deprecated-declarations below +# These flags are for development; we don't want production builds warning or erroring due to deprecation # DEFINES += QT_DEPRECATED_WARNINGS # uncomment this to get warnings about deprecated APIs -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 # disables all the APIs deprecated before Qt 5.15.0 +# DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 # disables all the APIs deprecated before Qt 5.15.0 +# DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060500 # disables all the APIs deprecated before Qt 6.5.0 # Bring in flag settings from the environment; see https://stackoverflow.com/a/17578151/2752221 diff --git a/QtSLiM/QtSLiMConsoleTextEdit.cpp b/QtSLiM/QtSLiMConsoleTextEdit.cpp index e633640a..40b0d0f2 100644 --- a/QtSLiM/QtSLiMConsoleTextEdit.cpp +++ b/QtSLiM/QtSLiMConsoleTextEdit.cpp @@ -659,7 +659,11 @@ void QtSLiMConsoleTextEdit::adjustSelectionAndReadOnly(void) void QtSLiMConsoleTextEdit::dragMoveEvent(QDragMoveEvent *p_event) { // Figure out where the drop would go +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QTextCursor dropCursor = cursorForPosition(p_event->pos()); +#else + QTextCursor dropCursor = cursorForPosition(p_event->position().toPoint()); +#endif //qDebug() << "dragMoveEvent: " << dropCursor.position(); diff --git a/QtSLiM/QtSLiMIndividualsWidget.cpp b/QtSLiM/QtSLiMIndividualsWidget.cpp index 7f222c12..e098d6ba 100644 --- a/QtSLiM/QtSLiMIndividualsWidget.cpp +++ b/QtSLiM/QtSLiMIndividualsWidget.cpp @@ -1835,7 +1835,11 @@ void QtSLiMIndividualsWidget::runContextMenuAtPoint(QPoint globalPoint, Subpopul std::string mapName; // If the user has selected a spatial map, extract its name +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) if (static_cast(action->data().type()) == QMetaType::QString) // for some reason this method's return type is apparently misdeclared; see the doc +#else + if (action->data().typeId() == QMetaType::QString) +#endif { QString qMapName = action->data().toString(); @@ -1960,7 +1964,11 @@ void QtSLiMIndividualsWidget::mousePressEvent(QMouseEvent *p_event) } if (subpopForEvent) +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) runContextMenuAtPoint(p_event->globalPos(), subpopForEvent); +#else + runContextMenuAtPoint(p_event->globalPosition().toPoint(), subpopForEvent); +#endif // redraw to get rid of action button highlight actionButtonHighlightSubpopID_ = -1; diff --git a/QtSLiM/QtSLiMPreferences.cpp b/QtSLiM/QtSLiMPreferences.cpp index 61675135..545e9cfe 100644 --- a/QtSLiM/QtSLiMPreferences.cpp +++ b/QtSLiM/QtSLiMPreferences.cpp @@ -54,8 +54,12 @@ static QFont &defaultDisplayFont(void) if (!defaultFont) { +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QFontDatabase fontdb; QStringList families = fontdb.families(); +#else + QStringList families = QFontDatabase::families(); +#endif // Use filter() to look for matches, since the foundry can be appended after the name (why isn't this easier??) if (families.filter("Consola").size() > 0) // good on Windows diff --git a/QtSLiM/QtSLiMScriptTextEdit.cpp b/QtSLiM/QtSLiMScriptTextEdit.cpp index 321b9048..898f859a 100644 --- a/QtSLiM/QtSLiMScriptTextEdit.cpp +++ b/QtSLiM/QtSLiMScriptTextEdit.cpp @@ -540,7 +540,11 @@ void QtSLiMTextEdit::mousePressEvent(QMouseEvent *p_event) fudgeFactor = std::round(fm.horizontalAdvance(" ") / 2.0) + 1; // added in Qt 5.11 #endif +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QPoint localPos = p_event->localPos().toPoint(); +#else + QPoint localPos = p_event->position().toPoint(); +#endif QPoint fudgedPoint(std::max(0, localPos.x() - fudgeFactor), localPos.y()); int characterPositionClicked = cursorForPosition(fudgedPoint).position(); @@ -3207,8 +3211,12 @@ void QtSLiMScriptTextEdit::lineNumberAreaMouseEvent(QMouseEvent *p_mouseEvent) // and return without doing anything. Note that Qt::RightButton is set for control-clicks! if (p_mouseEvent->button() == Qt::RightButton) return; - + +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QPointF localPos = p_mouseEvent->localPos(); +#else + QPointF localPos = p_mouseEvent->position(); +#endif qreal localY = localPos.y(); //qDebug() << "localY ==" << localY; diff --git a/QtSLiM/QtSLiMWindow.cpp b/QtSLiM/QtSLiMWindow.cpp index 0f6dcee4..6aeeb1a4 100644 --- a/QtSLiM/QtSLiMWindow.cpp +++ b/QtSLiM/QtSLiMWindow.cpp @@ -3284,7 +3284,7 @@ void QtSLiMWindow::displayProfileResults(void) profile_window->setLayout(window_layout); - window_layout->setMargin(0); + window_layout->setContentsMargins(0, 0, 0, 0); window_layout->setSpacing(0); window_layout->addWidget(textEdit); @@ -3317,8 +3317,12 @@ void QtSLiMWindow::displayProfileResults(void) QFont optimaFont; { // We want a body font of Optima on the Mac; on non-Mac platforms we'll just use the default system font for now +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QFontDatabase fontdb; QStringList families = fontdb.families(); +#else + QStringList families = QFontDatabase::families(); +#endif // Use filter() to look for matches, since the foundry can be appended after the name (why isn't this easier??) if (families.filter("Optima").size() > 0) // good on Mac diff --git a/QtSLiM/main.cpp b/QtSLiM/main.cpp index d5931b5c..df3ce261 100644 --- a/QtSLiM/main.cpp +++ b/QtSLiM/main.cpp @@ -262,8 +262,10 @@ int main(int argc, char *argv[]) linux_ForceDarkMode(); #endif - // Tell Qt to use high-DPI pixmaps for icons + // Tell Qt to use high-DPI pixmaps for icons; not needed in Qt6, which is always high-DPI +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif // On macOS, turn off the automatic quit on last window close, for Qt 5.15.2. // Builds against older Qt versions will just quit on the last window close, because