Gui: Fix comparison of argument of clicked() with StandardButton

Fixes #14639: Comparison between integers and StandardButton fails for Python task dialogs with PySide6
This commit is contained in:
wmayer
2024-06-13 15:44:18 +02:00
committed by Chris Hennes
parent 17eac1ab69
commit 594c382e5e
3 changed files with 23 additions and 1 deletions

View File

@@ -619,6 +619,25 @@ qsizetype PythonWrapper::toEnum(const Py::Object& pyobject)
return toEnum(pyobject.ptr());
}
Py::Object PythonWrapper::tryToStandardButton(qsizetype value)
{
std::stringstream cmd;
cmd << "from PySide import QtWidgets\n";
cmd << "btn = QtWidgets.QDialogButtonBox.StandardButton(" << value << ")";
return Py::asObject(Base::Interpreter().getValue(cmd.str().c_str(), "btn"));
}
Py::Object PythonWrapper::toStandardButton(qsizetype value)
{
try {
return tryToStandardButton(value);
}
catch (Py::Exception& e) {
e.clear();
return Py::Long(value);
}
}
QGraphicsItem* PythonWrapper::toQGraphicsItem(PyObject* pyPtr)
{
return qt_getCppType<QGraphicsItem>(pyPtr);