fix(Qt6): FTBFS with Qt 6

1. QMake project file should use dtk6 when build with Qt 6
2. FollowRedirects attr for QNetworkRequest is on by default on Qt 6
3. QLabel::pixmap() always return a QPixmap instead of a const pointer
This commit is contained in:
Wang Zichong
2026-01-15 13:27:52 +08:00
parent 5a790abb27
commit 14d7d26d0a
3 changed files with 7 additions and 4 deletions

View File

@@ -73,8 +73,9 @@ void AppIntoPage::openUrl(const QUrl &url)
iconRequest.setUrl(QUrl(pkgUrlBase + "/icon.png"));
iconRequest.setHeader(QNetworkRequest::UserAgentHeader, m_userAgent);
iconRequest.setHeader(QNetworkRequest::ContentTypeHeader, "charset='utf-8'");
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
iconRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
iconManager->get(iconRequest);
QObject::connect(iconManager, &QNetworkAccessManager::finished, [=](QNetworkReply *reply)
@@ -97,7 +98,9 @@ void AppIntoPage::openUrl(const QUrl &url)
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
request.setUrl(QUrl(imgUrl));
request.setHeader(QNetworkRequest::UserAgentHeader, m_userAgent);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
request.setHeader(QNetworkRequest::ContentTypeHeader, "charset='utf-8'");
manager->get(request);
QObject::connect(manager, &QNetworkAccessManager::finished, [=](QNetworkReply *reply)

View File

@@ -31,7 +31,8 @@ DEFINES += APP_BRANCH=\\\"'$$system(git symbolic-ref --short -q HEAD)'\\\"
# We want to capture all logs (INFO, DEBUG, WARNING, ERROR) for export to /tmp/spark-store
CONFIG += c++11 link_pkgconfig
PKGCONFIG += dtkcore dtkgui dtkwidget
equals(QT_MAJOR_VERSION, 6): PKGCONFIG += dtk6core dtk6gui dtk6widget
equals(QT_MAJOR_VERSION, 5): PKGCONFIG += dtkcore dtkgui dtkwidget
SOURCES += \
backend/DataCollectorAndUploader.cpp \

View File

@@ -10,8 +10,7 @@ CustomLabel::CustomLabel(QWidget *parent,
QPixmap CustomLabel::pixmap() const
{
const QPixmap* p = QLabel::pixmap();
return p ? *p : QPixmap();
return QLabel::pixmap();
}
void CustomLabel::setPixmap(const QPixmap &pixmap)