Qt6: fix possible build failure

* add CMake definitions 'QT_NO_KEYWORDS' to avoid the Qt definition of the 'slots' macro that causes a conflict when including Python headers
* drop QT3_SUPPORT define
This commit is contained in:
wmayer
2023-07-10 22:27:20 +02:00
committed by Chris Hennes
parent 0fcdeded7a
commit 8c0fd2706a
7 changed files with 18 additions and 12 deletions

View File

@@ -38,6 +38,8 @@ set(CMAKE_AUTOMOC TRUE)
set(CMAKE_AUTOUIC TRUE)
set(QtCore_MOC_EXECUTABLE ${Qt${FREECAD_QT_MAJOR_VERSION}Core_MOC_EXECUTABLE})
add_definitions(-DQT_NO_KEYWORDS)
message(STATUS "Set up to compile with Qt ${Qt${FREECAD_QT_MAJOR_VERSION}Core_VERSION}")
# In Qt 5.15 they added more generic names for these functions: "backport" those new names

View File

@@ -230,9 +230,13 @@ typedef unsigned __int64 uint64_t;
// Qt
// Make sure to explicitly use the correct conversion
#define QT_NO_CAST_FROM_ASCII
#undef QT3_SUPPORT
#define QT_NO_KEYWORDS
#ifndef QT_NO_CAST_FROM_ASCII
# define QT_NO_CAST_FROM_ASCII
#endif
#ifndef QT_NO_KEYWORDS
# define QT_NO_KEYWORDS
#endif
#if defined (FC_OS_WIN32) || defined(FC_OS_CYGWIN)
# ifndef QT_DLL

View File

@@ -148,7 +148,7 @@ QList<ActionLabel*> ActionBox::createItems(QList<QAction*> actions)
QLayout *l = createHBoxLayout();
foreach (QAction *action, actions) {
Q_FOREACH (QAction *action, actions) {
ActionLabel *act = createItem(action, l);
if (act)
list.append(act);

View File

@@ -39,7 +39,7 @@ void ActionPanel::setScheme(ActionPanelScheme *scheme)
// set scheme for children
QObjectList list(children());
foreach(QObject *obj, list) {
Q_FOREACH(QObject *obj, list) {
if (dynamic_cast<ActionGroup*>(obj)) {
((ActionGroup*)obj)->setScheme(scheme);
continue;

View File

@@ -60,7 +60,7 @@ ContextMenu::ContextMenu(QuarterWidget * quarterwidget)
QActionGroup * stereomodegroup = nullptr;
QActionGroup * transparencytypegroup = nullptr;
foreach (QAction * action, quarterwidget->renderModeActions()) {
Q_FOREACH (QAction * action, quarterwidget->renderModeActions()) {
if (!rendermodegroup) {
rendermodegroup = action->actionGroup();
} else {
@@ -73,7 +73,7 @@ ContextMenu::ContextMenu(QuarterWidget * quarterwidget)
rendermenu->addAction(action);
}
foreach (QAction * action, quarterwidget->stereoModeActions()) {
Q_FOREACH (QAction * action, quarterwidget->stereoModeActions()) {
if (!stereomodegroup) {
stereomodegroup = action->actionGroup();
} else {
@@ -86,7 +86,7 @@ ContextMenu::ContextMenu(QuarterWidget * quarterwidget)
stereomenu->addAction(action);
}
foreach (QAction * action, quarterwidget->transparencyTypeActions()) {
Q_FOREACH (QAction * action, quarterwidget->transparencyTypeActions()) {
if (!transparencytypegroup) {
transparencytypegroup = action->actionGroup();
} else {

View File

@@ -58,7 +58,7 @@ public:
this->windowsize = SbVec2s(event->size().width(),
event->size().height());
foreach(InputDevice * device, this->devices) {
Q_FOREACH(InputDevice * device, this->devices) {
device->setWindowSize(this->windowsize);
}
}
@@ -75,7 +75,7 @@ public:
SbVec2s mousepos(event->pos().x(), this->windowsize[1] - event->pos().y() - 1);
// the following corrects for high-dpi displays (e.g. mac retina)
mousepos *= quarterwidget->devicePixelRatio();
foreach(InputDevice * device, this->devices) {
Q_FOREACH(InputDevice * device, this->devices) {
device->setMousePosition(mousepos);
}
}
@@ -162,7 +162,7 @@ EventFilter::eventFilter(QObject * obj, QEvent * qevent)
// translate QEvent into SoEvent and see if it is handled by scene
// graph
foreach(InputDevice * device, PRIVATE(this)->devices) {
Q_FOREACH(InputDevice * device, PRIVATE(this)->devices) {
const SoEvent * soevent = device->translateEvent(qevent);
if (soevent && PRIVATE(this)->quarterwidget->processSoEvent(soevent)) {
return true;

View File

@@ -828,7 +828,7 @@ QuarterWidget::updateDevicePixelRatio() {
}
if(PRIVATE(this)->device_pixel_ratio != dev_pix_ratio) {
PRIVATE(this)->device_pixel_ratio = dev_pix_ratio;
emit devicePixelRatioChanged(dev_pix_ratio);
Q_EMIT devicePixelRatioChanged(dev_pix_ratio);
return true;
}
return false;