Skip to content

Commit 73b2bfa

Browse files
committed
Fix issues preventing library from building with Qt 6
1. CMake instructions now handle both Qt 6 and Qt 5 2. Pass correct QString-like type to setWindowTitle 3. Remove qAsConst optimization to address deprecation warning
1 parent b59d58f commit 73b2bfa

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

cmake/Qt6Portability.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
include_directories(${QtWidgets_INCLUDE_DIRS})
3+
4+
if(QT_USE_QTNETWORK)
5+
find_package(QtNetwork REQUIRED)
6+
list(APPEND QT_LIBRARIES Qt::Network)
7+
include_directories(${QtNetwork_INCLUDE_DIRS})
8+
endif()
9+
10+
if(QT_USE_QTXML)
11+
find_package(QtXml REQUIRED)
12+
list(APPEND QT_LIBRARIES Qt::Xml)
13+
include_directories(${QtXml_INCLUDE_DIRS})
14+
endif()
15+
16+
if(QT_USE_QTTEST)
17+
find_package(QtTest REQUIRED)
18+
list(APPEND QT_LIBRARIES Qt::Test)
19+
include_directories(${QtTest_INCLUDE_DIRS})
20+
endif()
21+
22+
macro(qt4_wrap_ui)
23+
qt_wrap_ui(${ARGN})
24+
endmacro()
25+
26+
macro(qt4_wrap_cpp)
27+
qt_wrap_cpp(${ARGN})
28+
endmacro()
29+
30+
macro(qt4_add_resources)
31+
qt_add_resources(${ARGN})
32+
endmacro()

examples/mactouchbar/mainwindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected].
2+
** Copyright (C) 2024 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected].
33
** All rights reserved.
44
**
55
** This file is part of the KD MacTouchBar library.
@@ -34,7 +34,7 @@
3434

3535
MainWindow::MainWindow()
3636
{
37-
setWindowTitle("KDMacTouchBar Example");
37+
setWindowTitle(tr("KDMacTouchBar Example"));
3838
resize(400, 200);
3939

4040
// attach a touchbar to this window

src/kdmactouchbar.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected].
2+
** Copyright (C) 2024 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected].
33
** All rights reserved.
44
**
55
** This file is part of the KD MacTouchBar library.
@@ -49,7 +49,7 @@
4949

5050
auto nsImage = [[[NSImage alloc] initWithSize:NSZeroSize] autorelease];
5151

52-
for (const auto& size : qAsConst(sizes)) {
52+
for (const auto& size : sizes) {
5353
const QImage qimage = icon.pixmap(size).toImage();
5454
CGImageRef cgImage = qimage.toCGImage();
5555
if (!cgImage)

0 commit comments

Comments
 (0)