diff --git a/src/PythonQt.cpp b/src/PythonQt.cpp index af220d8d0..e24acdffc 100644 --- a/src/PythonQt.cpp +++ b/src/PythonQt.cpp @@ -122,8 +122,6 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) } else { qRegisterMetaType("size_t"); } - int stringRefId = qRegisterMetaType("QStringRef"); - PythonQtConv::registerMetaTypeToPythonConverter(stringRefId, PythonQtConv::convertFromStringRef); int objectPtrListId = qRegisterMetaType >("QList"); PythonQtConv::registerMetaTypeToPythonConverter(objectPtrListId, PythonQtConv::convertFromQListOfPythonQtObjectPtr); @@ -239,7 +237,7 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) PythonQtRegisterToolClassesTemplateConverterForKnownClass(QLineF); PythonQtRegisterToolClassesTemplateConverterForKnownClass(QPoint); PythonQtRegisterToolClassesTemplateConverterForKnownClass(QPointF); - PythonQtRegisterToolClassesTemplateConverterForKnownClass(QRegExp); + PythonQtRegisterToolClassesTemplateConverterForKnownClass(QRegularExpression); PythonQtRegisterToolClassesTemplateConverterForKnownClass(QFont); PythonQtRegisterToolClassesTemplateConverterForKnownClass(QPixmap); @@ -257,7 +255,6 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) PythonQtRegisterToolClassesTemplateConverterForKnownClass(QPen); PythonQtRegisterToolClassesTemplateConverterForKnownClass(QTextLength); PythonQtRegisterToolClassesTemplateConverterForKnownClass(QTextFormat); - PythonQtRegisterToolClassesTemplateConverterForKnownClass(QMatrix); PyObject* pack = PythonQt::priv()->packageByName("QtCore"); PyObject* pack2 = PythonQt::priv()->packageByName("Qt"); diff --git a/src/PythonQtClassInfo.cpp b/src/PythonQtClassInfo.cpp index 17fb5d13c..61f3fadd2 100644 --- a/src/PythonQtClassInfo.cpp +++ b/src/PythonQtClassInfo.cpp @@ -554,7 +554,8 @@ QStringList PythonQtClassInfo::memberList() } } - return QSet::fromList(l).toList(); + QSet set(l.begin(), l.end()); + return set.values(); } const QByteArray& PythonQtClassInfo::className() const diff --git a/src/PythonQtClassWrapper.cpp b/src/PythonQtClassWrapper.cpp index 205338300..00e94a926 100644 --- a/src/PythonQtClassWrapper.cpp +++ b/src/PythonQtClassWrapper.cpp @@ -463,8 +463,8 @@ static PyObject *PythonQtClassWrapper_getattro(PyObject *obj, PyObject *name) } PyObject* dict = PyDict_New(); - QSet completeSet = QSet::fromList(wrapper->classInfo()->memberList()); - completeSet.unite(QSet::fromList(wrapper->classInfo()->propertyList())); + QSet completeSet(wrapper->classInfo()->memberList().begin(), wrapper->classInfo()->memberList().end()); + completeSet.unite(QSet(wrapper->classInfo()->propertyList().begin(), wrapper->classInfo()->propertyList().end())); Q_FOREACH (QString name, completeSet) { if (name.startsWith("py_")) { diff --git a/src/PythonQtConversion.cpp b/src/PythonQtConversion.cpp index a1aaa2914..2b444cdf6 100644 --- a/src/PythonQtConversion.cpp +++ b/src/PythonQtConversion.cpp @@ -1015,17 +1015,17 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) if (wrap->classInfo()->isCPPWrapper()) { if (wrap->classInfo()->metaTypeId()>0) { // construct a new variant from the C++ object if it has a meta type (this will COPY the object!) - v = QVariant(wrap->classInfo()->metaTypeId(), wrap->_wrappedPtr); + v = QVariant(QMetaType(wrap->classInfo()->metaTypeId()), wrap->_wrappedPtr); } else { // TODOXXX we could as well check if there is a registered meta type for "classname*", so that we may pass // the pointer here... // is this worth anything? we loose the knowledge of the cpp object type - v = qVariantFromValue(wrap->_wrappedPtr); + v = QVariant::fromValue(wrap->_wrappedPtr); } } else { // this gives us a QObject pointer QObject* myObject = wrap->_obj; - v = qVariantFromValue(myObject); + v = QVariant::fromValue(myObject); } return v; } else if (val == Py_None) { @@ -1073,55 +1073,55 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) case QMetaType::Float: { float d = (float) PyObjGetDouble(val,false,ok); - if (ok) v = qVariantFromValue(d); + if (ok) v = QVariant::fromValue(d); } break; case QMetaType::Long: { long d = (long) PyObjGetLongLong(val,false,ok); - if (ok) v = qVariantFromValue(d); + if (ok) v = QVariant::fromValue(d); } break; case QMetaType::ULong: { unsigned long d = (unsigned long) PyObjGetLongLong(val,false,ok); - if (ok) v = qVariantFromValue(d); + if (ok) v = QVariant::fromValue(d); } break; case QMetaType::LongLong: { qint64 d = PyObjGetLongLong(val, false, ok); - if (ok) v = qVariantFromValue(d); + if (ok) v = QVariant::fromValue(d); } break; case QMetaType::ULongLong: { quint64 d = PyObjGetULongLong(val, false, ok); - if (ok) v = qVariantFromValue(d); + if (ok) v = QVariant::fromValue(d); } break; case QMetaType::Short: { short d = (short) PyObjGetInt(val,false,ok); - if (ok) v = qVariantFromValue(d); + if (ok) v = QVariant::fromValue(d); } break; case QMetaType::UShort: { unsigned short d = (unsigned short) PyObjGetInt(val,false,ok); - if (ok) v = qVariantFromValue(d); + if (ok) v = QVariant::fromValue(d); } break; case QMetaType::Char: { char d = (char) PyObjGetInt(val,false,ok); - if (ok) v = qVariantFromValue(d); + if (ok) v = QVariant::fromValue(d); } break; case QMetaType::UChar: { unsigned char d = (unsigned char) PyObjGetInt(val,false,ok); - if (ok) v = qVariantFromValue(d); + if (ok) v = QVariant::fromValue(d); } break; @@ -1189,7 +1189,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)val; if (wrap->classInfo()->isCPPWrapper() && wrap->classInfo()->metaTypeId() == type) { // construct a new variant from the C++ object if it has the same meta type - v = QVariant(type, wrap->_wrappedPtr); + v = QVariant(QMetaType(type), wrap->_wrappedPtr); } else { // Try to convert the object to a QVariant based on the typeName bool ok; @@ -1202,10 +1202,10 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) void* object = castWrapperTo(wrap, typeName, ok); if (ok) { if (isPtr) { - v = QVariant(type, &object); + v = QVariant(QMetaType(type), &object); } else { - v = QVariant(type, object); + v = QVariant(QMetaType(type), object); } } } @@ -1215,7 +1215,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) PythonQtConvertPythonToMetaTypeCB* converter = _pythonToMetaTypeConverters.value(type); if (converter) { // allocate a default object of the needed type: - v = QVariant(type, (const void*)nullptr); + v = QVariant(QMetaType(type), (const void*)nullptr); // now call the converter, passing the internal object of the variant ok = (*converter)(val, (void*)v.constData(), type, true); if (!ok) { @@ -1226,7 +1226,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) const PythonQtMethodInfo::ParameterInfo& info = PythonQtMethodInfo::getParameterInfoForMetaType(type); if (info.isQList && (info.innerNamePointerCount == 1)) { // allocate a default object of the needed type: - v = QVariant(type, (const void*)nullptr); + v = QVariant(QMetaType(type), (const void*)nullptr); ok = ConvertPythonListToQListOfPointerType(val, (QList*)v.constData(), info, true); if (!ok) { v = QVariant(); @@ -1461,7 +1461,7 @@ QString PythonQtConv::CPPObjectToString(int type, const void* data) { // this creates a copy, but that should not be expensive for typical simple variants // (but we do not want to do this for our won user types! if (type>0 && type < (int)QVariant::UserType) { - QVariant v(type, data); + QVariant v(QMetaType(type), data); r = v.toString(); } } @@ -1483,11 +1483,6 @@ PyObject* PythonQtConv::createCopyFromMetaType( int type, const void* data ) return (PyObject*)wrap; } -PyObject* PythonQtConv::convertFromStringRef(const void* inObject, int /*metaTypeId*/) -{ - return PythonQtConv::QStringToPyObject(((QStringRef*)inObject)->toString()); -} - QByteArray PythonQtConv::getCPPTypeName(PyObject* type) { QByteArray result; diff --git a/src/PythonQtConversion.h b/src/PythonQtConversion.h index 1ff05bee7..28bb37aa5 100644 --- a/src/PythonQtConversion.h +++ b/src/PythonQtConversion.h @@ -185,7 +185,6 @@ class PYTHONQT_EXPORT PythonQtConv { static PyObject* convertFromPythonQtSafeObjectPtr(const void* /* PythonQtObjectPtr* */ inObject, int /*metaTypeId*/); static bool convertToQListOfPythonQtObjectPtr(PyObject* obj, void* /* QList* */ outList, int /*metaTypeId*/, bool /*strict*/); static PyObject* convertFromQListOfPythonQtObjectPtr(const void* /* QList* */ inObject, int /*metaTypeId*/); - static PyObject* convertFromStringRef(const void* inObject, int /*metaTypeId*/); //! Returns the name of the equivalent CPP type (for signals and slots) static QByteArray getCPPTypeName(PyObject* type); diff --git a/src/PythonQtImporter.cpp b/src/PythonQtImporter.cpp index dfcfcb165..519c06bd6 100644 --- a/src/PythonQtImporter.cpp +++ b/src/PythonQtImporter.cpp @@ -222,7 +222,7 @@ PythonQtImporter_load_module(PyObject *obj, PyObject *args) { PythonQtImporter *self = (PythonQtImporter *)obj; PyObject *code = nullptr, *mod = nullptr, *dict = nullptr; - char *fullname; + char *fullname = NULL; if (!PyArg_ParseTuple(args, "s:PythonQtImporter.load_module", &fullname)) @@ -338,7 +338,7 @@ PythonQtImporter_load_module(PyObject *obj, PyObject *args) QVariantList list = result.toList(); if (list.count()==3) { // We prepend the full module name (including package prefix) - list.prepend(fullname); + list.prepend(QString(fullname)); #ifdef __linux #ifdef _DEBUG // imp_find_module() does not respect the debug suffix '_d' on Linux, @@ -740,7 +740,7 @@ PythonQtImport::getCodeFromData(const QString& path, int isbytecode,int /*ispack QDateTime time; time = PythonQt::importInterface()->lastModifiedDate(path); QString cacheFilename = getCacheFilename(path, /*isOptimizedFilename=*/false); - writeCompiledModule((PyCodeObject*)code, cacheFilename, time.toTime_t(), /*sourceSize=*/qdata.length()); + writeCompiledModule((PyCodeObject*)code, cacheFilename, time.toSecsSinceEpoch(), /*sourceSize=*/qdata.length()); } } return code; @@ -754,7 +754,7 @@ PythonQtImport::getMTimeOfSource(const QString& path) if (PythonQt::importInterface()->exists(path2)) { QDateTime t = PythonQt::importInterface()->lastModifiedDate(path2); if (t.isValid()) { - mtime = t.toTime_t(); + mtime = t.toSecsSinceEpoch(); } } diff --git a/src/PythonQtMethodInfo.cpp b/src/PythonQtMethodInfo.cpp index 3c8ee7ff1..2ba42b258 100644 --- a/src/PythonQtMethodInfo.cpp +++ b/src/PythonQtMethodInfo.cpp @@ -372,7 +372,7 @@ int PythonQtMethodInfo::nameToType(const char* name) _parameterTypeDict.insert("QLineF", QMetaType::QLineF); _parameterTypeDict.insert("QPoint", QMetaType::QPoint); _parameterTypeDict.insert("QPointF", QMetaType::QPointF); - _parameterTypeDict.insert("QRegExp", QMetaType::QRegExp); + _parameterTypeDict.insert("QRegularExpression", QMetaType::QRegularExpression); _parameterTypeDict.insert("QFont", QMetaType::QFont); _parameterTypeDict.insert("QPixmap", QMetaType::QPixmap); _parameterTypeDict.insert("QBrush", QMetaType::QBrush); @@ -388,7 +388,6 @@ int PythonQtMethodInfo::nameToType(const char* name) _parameterTypeDict.insert("QPen", QMetaType::QPen); _parameterTypeDict.insert("QTextLength", QMetaType::QTextLength); _parameterTypeDict.insert("QTextFormat", QMetaType::QTextFormat); - _parameterTypeDict.insert("QMatrix", QMetaType::QMatrix); _parameterTypeDict.insert("QVariant", PythonQtMethodInfo::Variant); // own special types... (none so far, could be e.g. ObjectList } diff --git a/src/PythonQtSlot.cpp b/src/PythonQtSlot.cpp index 00f053263..084df8706 100644 --- a/src/PythonQtSlot.cpp +++ b/src/PythonQtSlot.cpp @@ -540,7 +540,7 @@ meth_get__doc__(PythonQtSlotFunctionObject * m, void * /*closure*/) if (!names.at(i - 1).isEmpty()) { doc += names.at(i - 1); } else { - doc += QString('a' + i - firstArgOffset).toLatin1(); + doc += QString(QChar((char) ('a' + i - firstArgOffset))).toLatin1(); } } doc += ")"; diff --git a/src/PythonQtStdDecorators.cpp b/src/PythonQtStdDecorators.cpp index b3e281393..ca1ddcfbc 100644 --- a/src/PythonQtStdDecorators.cpp +++ b/src/PythonQtStdDecorators.cpp @@ -45,6 +45,7 @@ #include "PythonQtConversion.h" #include +#include bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, PyObject* callable) { @@ -240,7 +241,7 @@ QList PythonQtStdDecorators::findChildren(QObject* parent, PyObject* t return list; } -QList PythonQtStdDecorators::findChildren(QObject* parent, PyObject* type, const QRegExp& regExp) +QList PythonQtStdDecorators::findChildren(QObject* parent, PyObject* type, const QRegularExpression& regExp) { const QMetaObject* meta = nullptr; QByteArray typeName; @@ -322,7 +323,7 @@ int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, c return 0; } -int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QRegExp& regExp, QList& list) +int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QRegularExpression& regExp, QList& list) { const QObjectList& children = parent->children(); int i; @@ -334,7 +335,8 @@ int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, c return -1; // Skip if the name doesn't match. - if (regExp.indexIn(obj->objectName()) == -1) + QRegularExpressionMatch match = regExp.match(obj->objectName()); + if (match.hasMatch() == false) continue; if ((typeName && obj->inherits(typeName)) || diff --git a/src/PythonQtStdDecorators.h b/src/PythonQtStdDecorators.h index b5c0ba607..cf2e7773d 100644 --- a/src/PythonQtStdDecorators.h +++ b/src/PythonQtStdDecorators.h @@ -58,6 +58,7 @@ #include #include #include +#include class PYTHONQT_EXPORT PythonQtStdDecorators : public QObject { @@ -82,7 +83,7 @@ public Q_SLOTS: const QObjectList* children(QObject* o); QObject* findChild(QObject* parent, PyObject* type, const QString& name = QString()); QList findChildren(QObject* parent, PyObject* type, const QString& name= QString()); - QList findChildren(QObject* parent, PyObject* type, const QRegExp& regExp); + QList findChildren(QObject* parent, PyObject* type, const QRegularExpression& regExp); bool setProperty(QObject* o, const char* name, const QVariant& value); QVariant property(QObject* o, const char* name); @@ -103,8 +104,8 @@ public Q_SLOTS: int static_Qt_qRound(double a) { return qRound(a); } qint64 static_Qt_qRound64(double a) { return qRound64(a); } const char* static_Qt_qVersion() { return qVersion(); } - int static_Qt_qrand() { return qrand(); } - void static_Qt_qsrand(uint a) { qsrand(a); } + int static_Qt_qrand() { return QRandomGenerator::global()->generate(); } + void static_Qt_qsrand(uint a) { QRandomGenerator::global()->seed(a); } QString tr(QObject* obj, const QString& text, const QString& ambig = QString(), int n = -1); @@ -116,7 +117,7 @@ public Q_SLOTS: private: QObject* findChild(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name); int findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name, QList& list); - int findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QRegExp& regExp, QList& list); + int findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QRegularExpression& regExp, QList& list); }; class PythonQtSingleShotTimer : public QTimer diff --git a/src/PythonQtVariants.h b/src/PythonQtVariants.h index 7e0691016..833f35c8a 100644 --- a/src/PythonQtVariants.h +++ b/src/PythonQtVariants.h @@ -54,7 +54,7 @@ #include #include #include -#include +#include #include #include @@ -72,7 +72,6 @@ #include #include #include -#include #endif diff --git a/src/gui/PythonQtScriptingConsole.h b/src/gui/PythonQtScriptingConsole.h index c47a0f023..26e028fa5 100644 --- a/src/gui/PythonQtScriptingConsole.h +++ b/src/gui/PythonQtScriptingConsole.h @@ -55,7 +55,7 @@ class PYTHONQT_EXPORT PythonQtScriptingConsole : public QTextEdit Q_OBJECT public: - PythonQtScriptingConsole(QWidget* parent, const PythonQtObjectPtr& context, Qt::WindowFlags i = 0); + PythonQtScriptingConsole(QWidget* parent, const PythonQtObjectPtr& context, Qt::WindowFlags i = Qt::WindowFlags()); ~PythonQtScriptingConsole() override; diff --git a/src/src.pro b/src/src.pro index 4d2627eab..4e9a78adf 100644 --- a/src/src.pro +++ b/src/src.pro @@ -4,7 +4,7 @@ # $Source$ # -------------------------------------------------- -TARGET = PythonQt-Qt5-PythonXY +TARGET = PythonQt-Qt6-PythonXY TEMPLATE = lib DESTDIR = ../lib @@ -25,12 +25,16 @@ isEmpty(PYTHONQT_STATIC) { DEFINES += PYTHONQT_CATCH_ALL_EXCEPTIONS -contains(QT_MAJOR_VERSION, 5) { +contains(QT_MAJOR_VERSION, 6) { QT += widgets core-private } INCLUDEPATH += $$PWD +macx { + QMAKE_APPLE_DEVICE_ARCHS = x86_64 arm64 +} + include ( ../build/common.prf ) include ( ../build/python.prf ) TARGET = $$replace(TARGET, PythonXY, Python$${PYTHON_VERSION})