diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index c5021e9685..29fc9b7ec0 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1866,18 +1866,24 @@ void Application::runApplication() #ifdef FC_OS_WIN32 SetProcessDPIAware(); // call before the main event loop #endif +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QApplication::setAttribute(Qt::AA_DisableHighDpiScaling); +#endif } else { // Enable automatic scaling based on pixel density of display (added in Qt 5.6) +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif #if QT_VERSION >= QT_VERSION_CHECK(5,14,0) QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); #endif } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) //Enable support for highres images (added in Qt 5.1, but off by default) QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif // Use software rendering for OpenGL ParameterGrp::handle hOpenGL = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/OpenGL"); diff --git a/src/Gui/Assistant.cpp b/src/Gui/Assistant.cpp index 4261768a1b..18fea10203 100644 --- a/src/Gui/Assistant.cpp +++ b/src/Gui/Assistant.cpp @@ -83,7 +83,11 @@ bool Assistant::startAssistant() #elif defined(Q_OS_MAC) QString app = QCoreApplication::applicationDirPath() + QDir::separator(); #else +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator(); +#else + QString app = QLibraryInfo::path(QLibraryInfo::BinariesPath) + QDir::separator(); +#endif #endif app += QLatin1String("assistant"); diff --git a/src/Gui/DlgCheckableMessageBox.cpp b/src/Gui/DlgCheckableMessageBox.cpp index 7cca4e6946..b0917fe93c 100644 --- a/src/Gui/DlgCheckableMessageBox.cpp +++ b/src/Gui/DlgCheckableMessageBox.cpp @@ -48,14 +48,31 @@ QByteArray toParamEntry(QString name) return name.toLatin1(); } +QPixmap getStandardIcon(QWidget* widget, QStyle::StandardPixmap standardPixmap) +{ + int iconSize = widget->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, nullptr, widget); + QIcon icon = widget->style()->standardIcon(standardPixmap); + if (!icon.isNull()) { +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + return icon.pixmap(QSize(iconSize, iconSize)); +#else + qreal dpr = widget->devicePixelRatio(); + return icon.pixmap(QSize(iconSize, iconSize), dpr); +#endif + } + + return QPixmap(); +} + void DlgCheckableMessageBox::showMessage(const QString& header, const QString& message, bool check, const QString& checkText) { bool checked = App::GetApplication().GetParameterGroupByPath(QByteArray("User parameter:BaseApp/CheckMessages"))->GetBool(toParamEntry(header)); if (!checked) { auto mb = new DlgCheckableMessageBox(Gui::getMainWindow()); + mb->setWindowTitle(header); - mb->setIconPixmap(QMessageBox::standardIcon(QMessageBox::Warning)); + mb->setIconPixmap(getStandardIcon(mb, QStyle::SP_MessageBoxWarning)); mb->setText(message); mb->setPrefEntry(header); mb->setCheckBoxText(checkText); @@ -65,6 +82,7 @@ void DlgCheckableMessageBox::showMessage(const QString& header, const QString& m mb->show(); } } + void DlgCheckableMessageBox::showMessage(const QString& header, const QString& message, const QString& prefPath, const QString& paramEntry, bool entryDefault, bool check, const QString& checkText) { @@ -72,8 +90,9 @@ void DlgCheckableMessageBox::showMessage(const QString& header, const QString& m if(checked == entryDefault) { auto mb = new Gui::Dialog::DlgCheckableMessageBox(Gui::getMainWindow()); + mb->setWindowTitle(header); - mb->setIconPixmap(QMessageBox::standardIcon(QMessageBox::Warning)); + mb->setIconPixmap(getStandardIcon(mb, QStyle::SP_MessageBoxWarning)); mb->setText(message); mb->setPrefPath(prefPath); mb->setPrefEntry(paramEntry); @@ -239,7 +258,7 @@ QDialogButtonBox::StandardButton { DlgCheckableMessageBox mb(parent); mb.setWindowTitle(title); - mb.setIconPixmap(QMessageBox::standardIcon(QMessageBox::Question)); + mb.setIconPixmap(getStandardIcon(&mb, QStyle::SP_MessageBoxQuestion)); mb.setText(question); mb.setCheckBoxText(checkBoxText); mb.setChecked(*checkBoxSetting); diff --git a/src/Gui/DlgExpressionInput.cpp b/src/Gui/DlgExpressionInput.cpp index 53c3a8efd9..f670761ee5 100644 --- a/src/Gui/DlgExpressionInput.cpp +++ b/src/Gui/DlgExpressionInput.cpp @@ -65,7 +65,7 @@ DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path, } else { QVariant text = parent->property("text"); - if (text.canConvert(QMetaType::QString)) { + if (text.canConvert()) { ui->expression->setText(text.toString()); } } diff --git a/src/Gui/Flag.cpp b/src/Gui/Flag.cpp index 1c9703f035..d5cae36f34 100644 --- a/src/Gui/Flag.cpp +++ b/src/Gui/Flag.cpp @@ -132,7 +132,11 @@ void Flag::resizeEvent(QResizeEvent* e) void Flag::mouseMoveEvent(QMouseEvent *e) { if (e->buttons() & Qt::LeftButton) { +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) move(e->globalPos() - dragPosition); +#else + move(e->globalPosition().toPoint() - dragPosition); +#endif e->accept(); auto viewer = dynamic_cast(parentWidget()); if (viewer) @@ -143,7 +147,11 @@ void Flag::mouseMoveEvent(QMouseEvent *e) void Flag::mousePressEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton) { +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) dragPosition = e->globalPos() - frameGeometry().topLeft(); +#else + dragPosition = e->globalPosition().toPoint() - frameGeometry().topLeft(); +#endif e->accept(); } } diff --git a/src/Gui/Language/Translator.cpp b/src/Gui/Language/Translator.cpp index 98186b20ca..8bf7f4e957 100644 --- a/src/Gui/Language/Translator.cpp +++ b/src/Gui/Language/Translator.cpp @@ -372,7 +372,11 @@ bool Translator::eventFilter(QObject* obj, QEvent* ev) if ((mod & Qt::KeypadModifier) && (key == Qt::Key_Period || key == Qt::Key_Comma)) { if (ev->spontaneous()) { auto dp = QString(QLocale().decimalPoint()); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) int dpcode = QKeySequence(dp)[0]; +#else + int dpcode = QKeySequence(dp)[0].key(); +#endif if (kev->text() != dp) { QKeyEvent modifiedKeyEvent(kev->type(), dpcode, mod, dp, kev->isAutoRepeat(), kev->count()); qApp->sendEvent(obj, &modifiedKeyEvent); diff --git a/src/Gui/MDIView.cpp b/src/Gui/MDIView.cpp index 6684ee5c6d..bfb317e94b 100644 --- a/src/Gui/MDIView.cpp +++ b/src/Gui/MDIView.cpp @@ -24,6 +24,7 @@ #ifndef _PreComp_ # include +# include # include # include # include @@ -151,12 +152,12 @@ void MDIView::onRelabel(Gui::Document *pDoc) QRegularExpression rx(QLatin1String("(\\s\\:\\s\\d+\\[\\*\\])$")); QRegularExpressionMatch match; //int pos = - cap.lastIndexOf(rx, -1, &match); + boost::ignore_unused(cap.lastIndexOf(rx, -1, &match)); if (!match.hasMatch()) { // ... or not rx.setPattern(QLatin1String("(\\s\\:\\s\\d+)$")); //pos = - cap.lastIndexOf(rx, -1, &match); + boost::ignore_unused(cap.lastIndexOf(rx, -1, &match)); } if (match.hasMatch()) { cap = QString::fromUtf8(pDoc->getDocument()->Label.getValue()); diff --git a/src/Gui/NetworkRetriever.cpp b/src/Gui/NetworkRetriever.cpp index 9c4d9d5f15..2affba60d6 100644 --- a/src/Gui/NetworkRetriever.cpp +++ b/src/Gui/NetworkRetriever.cpp @@ -495,7 +495,7 @@ void StdCmdDownloadOnlineHelp::activated(int iMsg) if (QMessageBox::critical(getMainWindow(), tr("Non-existing directory"), tr("The directory '%1' does not exist.\n\n" "Do you want to specify an existing directory?").arg(fi.filePath()), - QMessageBox::Yes|QMessageBox::Default, QMessageBox::No|QMessageBox::Escape) != + QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) { // exit the command @@ -513,7 +513,7 @@ void StdCmdDownloadOnlineHelp::activated(int iMsg) if (QMessageBox::critical(getMainWindow(), tr("Missing permission"), tr("You don't have write permission to '%1'\n\n" "Do you want to specify another directory?").arg(fi.filePath()), - QMessageBox::Yes|QMessageBox::Default, QMessageBox::No|QMessageBox::Escape) != + QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) { // exit the command diff --git a/src/Gui/ProgressBar.cpp b/src/Gui/ProgressBar.cpp index 4ebd809056..7e9a482c89 100644 --- a/src/Gui/ProgressBar.cpp +++ b/src/Gui/ProgressBar.cpp @@ -486,9 +486,9 @@ void ProgressBar::aboutToHide() bool ProgressBar::canAbort() const { - int ret = QMessageBox::question(getMainWindow(),tr("Aborting"), - tr("Do you really want to abort the operation?"), QMessageBox::Yes, - QMessageBox::No|QMessageBox::Default); + auto ret = QMessageBox::question(getMainWindow(),tr("Aborting"), + tr("Do you really want to abort the operation?"), QMessageBox::Yes | QMessageBox::No, + QMessageBox::No); return (ret == QMessageBox::Yes) ? true : false; } diff --git a/src/Gui/ProgressDialog.cpp b/src/Gui/ProgressDialog.cpp index 40d06c2b5a..66b06be305 100644 --- a/src/Gui/ProgressDialog.cpp +++ b/src/Gui/ProgressDialog.cpp @@ -319,9 +319,9 @@ void ProgressDialog::onCancel() bool ProgressDialog::canAbort() const { - int ret = QMessageBox::question(getMainWindow(),tr("Aborting"), - tr("Do you really want to abort the operation?"), QMessageBox::Yes, - QMessageBox::No|QMessageBox::Default); + auto ret = QMessageBox::question(getMainWindow(),tr("Aborting"), + tr("Do you really want to abort the operation?"), QMessageBox::Yes | QMessageBox::No, + QMessageBox::No); return (ret == QMessageBox::Yes) ? true : false; } diff --git a/src/Gui/PythonConsole.cpp b/src/Gui/PythonConsole.cpp index 791d3acb93..0362fc51dc 100644 --- a/src/Gui/PythonConsole.cpp +++ b/src/Gui/PythonConsole.cpp @@ -852,7 +852,7 @@ void PythonConsole::runSource(const QString& line) if (check) { ret = QMessageBox::question(this, tr("System exit"), tr("The application is still running.\nDo you want to exit without saving your data?"), - QMessageBox::Yes, QMessageBox::No|QMessageBox::Escape|QMessageBox::Default); + QMessageBox::Yes | QMessageBox::No, QMessageBox::No); } if (ret == QMessageBox::Yes) { PyErr_Clear(); @@ -1017,7 +1017,11 @@ void PythonConsole::dropEvent (QDropEvent * e) else { // always copy text when doing drag and drop if (mimeData->hasText()) { +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QTextCursor cursor = this->cursorForPosition(e->pos()); +#else + QTextCursor cursor = this->cursorForPosition(e->position().toPoint()); +#endif QTextCursor inputLineBegin = this->inputBegin(); if (!cursorBeyond( cursor, inputLineBegin )) { @@ -1025,7 +1029,11 @@ void PythonConsole::dropEvent (QDropEvent * e) QRect newPos = this->cursorRect(); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QDropEvent newEv(QPoint(newPos.x(), newPos.y()), Qt::CopyAction, mimeData, e->mouseButtons(), e->keyboardModifiers()); +#else + QDropEvent newEv(QPoint(newPos.x(), newPos.y()), Qt::CopyAction, mimeData, e->buttons(), e->modifiers()); +#endif e->accept(); QPlainTextEdit::dropEvent(&newEv); } diff --git a/src/Gui/QSint/actionpanel/taskheader_p.cpp b/src/Gui/QSint/actionpanel/taskheader_p.cpp index ca6288d253..871043cf3a 100644 --- a/src/Gui/QSint/actionpanel/taskheader_p.cpp +++ b/src/Gui/QSint/actionpanel/taskheader_p.cpp @@ -168,7 +168,11 @@ void TaskHeader::animate() update(); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) void TaskHeader::enterEvent ( QEvent * /*event*/ ) +#else +void TaskHeader::enterEvent ( QEnterEvent * /*event*/ ) +#endif { m_over = true; diff --git a/src/Gui/QSint/actionpanel/taskheader_p.h b/src/Gui/QSint/actionpanel/taskheader_p.h index 7d6e52243c..482a86db9f 100644 --- a/src/Gui/QSint/actionpanel/taskheader_p.h +++ b/src/Gui/QSint/actionpanel/taskheader_p.h @@ -47,14 +47,18 @@ protected Q_SLOTS: void animate(); protected: - virtual void paintEvent ( QPaintEvent * event ); - virtual void enterEvent ( QEvent * event ); - virtual void leaveEvent ( QEvent * event ); - virtual void mouseReleaseEvent ( QMouseEvent * event ); - virtual void keyPressEvent ( QKeyEvent * event ); - virtual void keyReleaseEvent ( QKeyEvent * event ); + void paintEvent ( QPaintEvent * event ) override; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + void enterEvent ( QEvent * event ) override; +#else + void enterEvent ( QEnterEvent * event ) override; +#endif + void leaveEvent ( QEvent * event ) override; + void mouseReleaseEvent ( QMouseEvent * event ) override; + void keyPressEvent ( QKeyEvent * event ) override; + void keyReleaseEvent ( QKeyEvent * event ) override; - bool eventFilter(QObject *obj, QEvent *event); + bool eventFilter(QObject *obj, QEvent *event) override; void changeIcons(); diff --git a/src/Gui/Quarter/EventFilter.cpp b/src/Gui/Quarter/EventFilter.cpp index 789c4d2f09..51a72a7c60 100644 --- a/src/Gui/Quarter/EventFilter.cpp +++ b/src/Gui/Quarter/EventFilter.cpp @@ -66,7 +66,11 @@ public: void trackPointerPosition(QMouseEvent * event) { assert(this->windowsize[1] != -1); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) this->globalmousepos = event->globalPos(); +#else + this->globalmousepos = event->globalPosition().toPoint(); +#endif SbVec2s mousepos(event->pos().x(), this->windowsize[1] - event->pos().y() - 1); // the following corrects for high-dpi displays (e.g. mac retina) diff --git a/src/Gui/TaskCSysDragger.cpp b/src/Gui/TaskCSysDragger.cpp index 85e7460a38..c99dffffd3 100644 --- a/src/Gui/TaskCSysDragger.cpp +++ b/src/Gui/TaskCSysDragger.cpp @@ -79,7 +79,8 @@ void TaskCSysDragger::setupGui() auto tLabel = new QLabel(tr("Translation Increment:"), incrementsBox); gridLayout->addWidget(tLabel, 0, 0, Qt::AlignRight); - int spinBoxWidth = QApplication::fontMetrics().averageCharWidth() * 20; + QFontMetrics metrics(QApplication::font()); + int spinBoxWidth = metrics.averageCharWidth() * 20; tSpinBox = new QuantitySpinBox(incrementsBox); tSpinBox->setMinimum(0.0); tSpinBox->setMaximum(std::numeric_limits::max()); diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index d30a1c39df..b2cd89a911 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -1493,7 +1493,11 @@ void TreeWidget::dragMoveEvent(QDragMoveEvent* event) return; auto modifier = QApplication::queryKeyboardModifiers(); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QTreeWidgetItem* targetItem = itemAt(event->pos()); +#else + QTreeWidgetItem* targetItem = itemAt(event->position().toPoint()); +#endif if (!targetItem || targetItem->isSelected()) { leaveEvent(nullptr); event->ignore(); @@ -1634,7 +1638,11 @@ void TreeWidget::dropEvent(QDropEvent* event) //FIXME: This should actually be done inside dropMimeData bool touched = false; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QTreeWidgetItem* targetItem = itemAt(event->pos()); +#else + QTreeWidgetItem* targetItem = itemAt(event->position().toPoint()); +#endif // not dropped onto an item if (!targetItem) return; diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index 701d5c98c9..e199d5ee8b 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -562,9 +562,9 @@ Py::Object PyResource::value(const Py::Tuple& args) } Py::Object item = Py::None(); - switch (v.type()) + switch (v.userType()) { - case QVariant::StringList: + case QMetaType::QStringList: { QStringList str = v.toStringList(); int nSize = str.count(); @@ -574,21 +574,21 @@ Py::Object PyResource::value(const Py::Tuple& args) } item = slist; } break; - case QVariant::ByteArray: + case QMetaType::QByteArray: break; - case QVariant::String: + case QMetaType::QString: item = Py::String(v.toString().toLatin1()); break; - case QVariant::Double: + case QMetaType::Double: item = Py::Float(v.toDouble()); break; - case QVariant::Bool: + case QMetaType::Bool: item = Py::Boolean(v.toBool() ? 1 : 0); break; - case QVariant::UInt: + case QMetaType::UInt: item = Py::Long(static_cast(v.toUInt())); break; - case QVariant::Int: + case QMetaType::Int: item = Py::Int(v.toInt()); break; default: diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index b6d5afd02c..922ae27309 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -760,7 +760,7 @@ QVariant PropertyStringItem::value(const App::Property* prop) const void PropertyStringItem::setValue(const QVariant& value) { if(!hasExpression()) { - if (!value.canConvert(QVariant::String)) + if (!value.canConvert()) return; QString val = value.toString(); val = QString::fromUtf8(Base::Interpreter().strToPython(val.toUtf8()).c_str()); @@ -813,7 +813,7 @@ QVariant PropertyFontItem::value(const App::Property* prop) const void PropertyFontItem::setValue(const QVariant& value) { - if (hasExpression() || !value.canConvert(QVariant::String)) + if (hasExpression() || !value.canConvert()) return; QString val = value.toString(); QString data = QString::fromLatin1("\"%1\"").arg(val); @@ -832,8 +832,11 @@ QWidget* PropertyFontItem::createEditor(QWidget* parent, const QObject* receiver void PropertyFontItem::setEditorData(QWidget *editor, const QVariant& data) const { auto cb = qobject_cast(editor); - QFontDatabase fdb; - QStringList familyNames = fdb.families(QFontDatabase::Any); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + QStringList familyNames = QFontDatabase().families(QFontDatabase::Any); +#else + QStringList familyNames = QFontDatabase::families(QFontDatabase::Any); +#endif cb->addItems(familyNames); int index = familyNames.indexOf(data.toString()); cb->setCurrentIndex(index); @@ -877,7 +880,7 @@ void PropertyIntegerItem::setValue(const QVariant& value) { //if the item has an expression it issues the python code if (!hasExpression()) { - if (!value.canConvert(QVariant::Int)) + if (!value.canConvert()) return; int val = value.toInt(); QString data = QString::fromLatin1("%1").arg(val); @@ -944,7 +947,7 @@ void PropertyIntegerConstraintItem::setValue(const QVariant& value) { //if the item has an expression it issues the python code if (!hasExpression()) { - if (!value.canConvert(QVariant::Int)) + if (!value.canConvert()) return; int val = value.toInt(); QString data = QString::fromLatin1("%1").arg(val); @@ -1038,7 +1041,7 @@ void PropertyFloatItem::setValue(const QVariant& value) { //if the item has an expression it issues the python code if (!hasExpression()) { - if (!value.canConvert(QVariant::Double)) + if (!value.canConvert()) return; double val = value.toDouble(); QString data = QString::fromLatin1("%1").arg(val, 0, 'f', decimals()); @@ -1214,7 +1217,7 @@ void PropertyFloatConstraintItem::setValue(const QVariant& value) { //if the item has an expression it issues the python code if (!hasExpression()) { - if (!value.canConvert(QVariant::Double)) + if (!value.canConvert()) return; double val = value.toDouble(); QString data = QString::fromLatin1("%1").arg(val, 0, 'f', decimals()); @@ -1313,7 +1316,7 @@ QVariant PropertyBoolItem::value(const App::Property* prop) const void PropertyBoolItem::setValue(const QVariant& value) { - if (hasExpression() || !value.canConvert(QVariant::Bool)) + if (hasExpression() || !value.canConvert()) return; bool val = value.toBool(); QString data = (val ? QLatin1String("True") : QLatin1String("False")); @@ -2827,7 +2830,7 @@ void PropertyEnumItem::setValue(const QVariant& value) QString data; - if (value.type() == QVariant::StringList) { + if (value.userType() == QMetaType::QStringList) { QStringList values = value.toStringList(); QTextStream str(&data); str << "["; @@ -2841,7 +2844,7 @@ void PropertyEnumItem::setValue(const QVariant& value) } str << "]"; } - else if (value.canConvert(QVariant::String)) { + else if (value.canConvert()) { QByteArray val = value.toString().toUtf8(); std::string str = Base::Tools::escapedUnicodeFromUtf8(val); data = QString::fromLatin1("u\"%1\"").arg(QString::fromStdString(str)); @@ -3058,7 +3061,7 @@ QVariant PropertyStringListItem::value(const App::Property* prop) const void PropertyStringListItem::setValue(const QVariant& value) { - if (hasExpression() || !value.canConvert(QVariant::StringList)) + if (hasExpression() || !value.canConvert()) return; QStringList values = value.toStringList(); QString data; @@ -3137,7 +3140,7 @@ QVariant PropertyFloatListItem::value(const App::Property* prop) const void PropertyFloatListItem::setValue(const QVariant& value) { - if (hasExpression() || !value.canConvert(QVariant::StringList)) + if (hasExpression() || !value.canConvert()) return; QStringList values = value.toStringList(); QString data; @@ -3212,7 +3215,7 @@ QVariant PropertyIntegerListItem::value(const App::Property* prop) const void PropertyIntegerListItem::setValue(const QVariant& value) { - if (hasExpression() || !value.canConvert(QVariant::StringList)) + if (hasExpression() || !value.canConvert()) return; QStringList values = value.toStringList(); QString data; @@ -4109,7 +4112,7 @@ QVariant PropertyFileItem::value(const App::Property* prop) const void PropertyFileItem::setValue(const QVariant& value) { - if (hasExpression() || !value.canConvert(QVariant::String)) + if (hasExpression() || !value.canConvert()) return; QString val = value.toString(); QString data = QString::fromLatin1("\"%1\"").arg(val); @@ -4168,7 +4171,7 @@ QVariant PropertyPathItem::value(const App::Property* prop) const void PropertyPathItem::setValue(const QVariant& value) { - if (hasExpression() || !value.canConvert(QVariant::String)) + if (hasExpression() || !value.canConvert()) return; QString val = value.toString(); QString data = QString::fromLatin1("\"%1\"").arg(val); @@ -4220,7 +4223,7 @@ QVariant PropertyTransientFileItem::value(const App::Property* prop) const void PropertyTransientFileItem::setValue(const QVariant& value) { - if (hasExpression() || !value.canConvert(QVariant::String)) + if (hasExpression() || !value.canConvert()) return; QString val = value.toString(); QString data = QString::fromLatin1("\"%1\"").arg(val); diff --git a/src/Gui/propertyeditor/PropertyModel.cpp b/src/Gui/propertyeditor/PropertyModel.cpp index a4bf6bbd04..3be45d4d32 100644 --- a/src/Gui/propertyeditor/PropertyModel.cpp +++ b/src/Gui/propertyeditor/PropertyModel.cpp @@ -82,7 +82,7 @@ bool PropertyModel::setData(const QModelIndex& index, const QVariant & value, in if (role == Qt::EditRole) { auto item = static_cast(index.internalPointer()); QVariant data = item->data(index.column(), role); - if (data.type() == QVariant::Double && value.type() == QVariant::Double) { + if (data.userType() == QMetaType::Double && value.userType() == QMetaType::Double) { // since we store some properties as floats we get some round-off // errors here. Thus, we use an epsilon here. // NOTE: Since 0.14 PropertyFloat uses double precision, so this is maybe unnecessary now?