aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/glue/qtwidgets.cpp
Commit message (Collapse)AuthorAgeFilesLines
* shiboken6: Enable code snippets for templatesFriedemann Kleint2025-02-201-0/+10
| | | | | | | | | | | Prototypically move some template code from QtGui into snippets. [ChangeLog][shiboken6] It is now possible to use file snippets for XML template content. Change-Id: Ifb23407819c843e9059225a5bd269d954f837ee3 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* limited api: Remove PyTuple_GET_ITEM, PyTuple_SET_ITEM, and PyTuple_GET_SIZE ↵Cristián Maureira-Fredes2024-11-081-11/+11
| | | | | | | | | | | macros Removing old macros for compatibility with the limited api, and refactoring some of their usages Change-Id: I33954199d2ef9884c64b963863b97aed851c440f Pick-to: 6.8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add QMessageBox.open() with a slotFriedemann Kleint2024-07-041-0/+6
| | | | | | | | | Extract a helper function from QTimer::singleShot() implementation and use that to implement it. Fixes: PYSIDE-2805 Change-Id: Ib758d355b36c598052cfa495b53d7da423999976 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Shiboken: Simplify Python Error MessagesChristian Tismer2024-05-101-4/+2
| | | | | | | | | | | | | | | | | | | The function PyErr_SetString is used quite often, which has no return value. The bracketed sequence PyErr_SetString(...); return nullptr; can in most cases be replaced by a single call to return PyErr_Format(...); To simplify matters, PyErr_Format is now used everywhere. Task-number: PYSIDE-2404 Change-Id: I5988fcd2430be700415d14d7a5cc740211e61d08 Pick-to: 6.7 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* Release dialogs when using QDialog.exec()Friedemann Kleint2024-04-121-0/+8
| | | | | | | | | | | | | | | In the typical pattern ported from C++ dialog = QDialog(mainWin) dialog.exec() one would expected the dialog to be deleted. However, due to the constructor heuristics creating a parent-child relationship, the dialog leaks. Add a modification to remove the relationship in case exec() is called. Change-Id: Ibc6f8c150cbd80a4085af4a5b713ee7c2c62abf3 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Fix crash when adding None to a QLayoutFriedemann Kleint2024-03-141-8/+33
| | | | | | | | | | | | | | | This caused a crash in PySide's addLayoutOwnership() code snippet, whereas Qt errors out with a warning. Guard all input parameters of the layout snippets with a check. Rename the snippet "addownership-0" which is used for the itemAt() functions "addownership-item-at" for clarity and add a check there. Pick-to: 6.6 6.5 Fixes: PYSIDE-2638 Change-Id: Ia89532059e7a27cc38d790a0d17e24e19d68887f Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix error about deleted C++ object when calling QWidget.style() in embedded ↵Friedemann Kleint2024-03-011-5/+10
| | | | | | | | | | | | application Do not create a parent relationship if the application was not created in Python. Fixes: PYSIDE-2605 Change-Id: I55e96b2f7120d557b1c1c62499843c053bf53945 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* shiboken: Fix the polymorphic names in styleOptionTypeChristian Tismer2024-02-121-22/+22
| | | | | | | | | | | | | There is a bug that actually creates new types instead of using the existing ones. Amends de5f162a70dda9d74cfce2337a9f90ddcb4ca75f Change-Id: I9516574d04465b206777e86f46df593ea53fcc43 Pick-to: 6.6 Task-number: PYSIDE-2404 Fixes: PYSIDE-1909 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken: Get rid of tp_dict in general, amendedChristian Tismer2023-10-111-1/+2
| | | | | | | | | | | | | | | | | | A few more cases of cppgenerator were added. This are now really all cases, because tp_dict is no longer exported. As a very positive side effect, there is no longer direct tp_dict access in the "init_<type>" functions. Usage of PepType_GetDict would have created a permanent extra-reference. NOTE: It was necessary to set SKIP_UNITY_BUILD_INCLUSION on pep384impl.cpp in order to let this work with unity. Change-Id: I021dbc978b51265db96d5d3d438e06aa96230cc1 Pick-to: 6.2 6.5 6.6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* layouts: error instead of segfault for invalid itemCristián Maureira-Fredes2023-08-241-0/+6
| | | | | | | Pick-to: 6.5 Fixes: PYSIDE-2422 Change-Id: Id07b891083e11577e21c2ac2a429ef453328830e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix warning about unused allow-thread attribute on add-functionFriedemann Kleint2023-07-261-0/+2
| | | | | | | | | | | | | Allow-thread must be done in code for add-function. Fixes: typesystem_widgets_common.xml:537:164: Warning: 1 attributes(s) unused on <add-function>: allow-thread="yes" Amends 65e48138e166c3575dfe23dfec259e112302fd28. Task-number: PYSIDE-2384 Change-Id: Idf906c27fb3caa2361cff71ccca5f5385881ae40 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide6: Add QWizardPage::registerField() with a signal instancFriedemann Kleint2023-07-261-0/+12
| | | | | | Fixes: PYSIDE-2384 Change-Id: Iad7a26385b40267308c287b8f6a4915972468574 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Handle returning primitive types by pointerFriedemann Kleint2023-03-141-1/+1
| | | | | | | | | | | | | | | This manifests in QtDataVisualization's const QBarDataArray *QBarDataProxy::array() const where QBarDataArray is handled as a primitive type. This required adapting a code snippet which was relying on the argument QString* being treated as QString. Task-number: PYSIDE-2206 Change-Id: Ib05f01d7b54e103cf5bb71be86ffa9b5067ca3fb Reviewed-by: Christian Tismer <tismer@stackless.com>
* nogil: Apply the first necessary fixesChristian Tismer2023-02-081-1/+1
| | | | | | | | | | | | | In a few old patches, we had not updated ob_refcnt to Py_REFCNT. This will now be necessary when we try the nogil branch. Thanks to Jim Kring for providing this initial patch. Task-number: PYSIDE-2221 Change-Id: I2085407e44d93faf4929aac24facef167f09ac52 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* PySide6: Fix CMake UNITY_BUILD (jumbo) builds for modulesFriedemann Kleint2022-12-161-0/+7
| | | | | | | | Use a header-guard like technique to prevent clashes. Task-number: PYSIDE-2155 Change-Id: I942f65ef326ede3e29d7afca301da5a14fe5b0a2 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Port from qAsConst() to std::as_const()Friedemann Kleint2022-10-131-1/+1
| | | | | | | | qAsConst() will be deprecated in Qt 6.5. Task-number: QTBUG-99313 Change-Id: Ibc7c2e26b0e52cec905a406ef081e0b99bcce50f Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix random values in QFormLayout.getItemPosition()Adrian Herrmann2022-08-181-0/+5
| | | | | | | | | | | | In QFormLayout::getItemPosition() on the C++ side, *rolePtr is not set if row == -1, in which case on the Python side this gets converted to a random value outside the enum range. Fix this by setting *rolePtr to a default value in the glue code. Pick-to: 6.2 6.3 Change-Id: I0c67c771ed017f14b211fa6ccf9c89706152d214 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Use SPDX license identifiersLucie Gérard2022-05-271-38/+2
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: I065150015bdb84a3096b5b39c061cf0a20ab637d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Introduce a function to get the type name of a polymorphic classFriedemann Kleint2022-05-051-0/+57
| | | | | | | | | | Helps for hierarchies that do not have virtual destructors where the default typeid(t).name() does not work (QStyleOption). Pick-to: 6.3 Fixes: PYSIDE-1909 Change-Id: I9ce3769a8c3550d011023597eede0ae6f8c9ad68 Reviewed-by: Christian Tismer <tismer@stackless.com>
* QFileDialog: allow threads with modal dialogsCristián Maureira-Fredes2022-01-241-0/+2
| | | | | | | | | | | The snippets that were used to get the return from a QFileDialog modal call was blocking, so we explicitly allow threads around the C++ call. Fixes: PYSIDE-1792 Pick-to: 6.2 Change-Id: Ifb06e8726fece6a9b8248bc91e7616101a8a99a2 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Adapt to the QWidget/addAction changes in 6.3Friedemann Kleint2022-01-131-43/+75
| | | | | | | | | qtbase/08e4d2db084f6abbf1840ffb694b15bd215ad069 moved the addAction() functions from QToolBar/QMenuBar and QMenu to QWidget. Change-Id: Ifcfe3743328712c5d0f1f5700a708c35838ead07 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Define SbkObjectType to be a PyTypeObjectFriedemann Kleint2021-09-111-1/+1
| | | | | | | | | | | | | | | SbkObjectType was a struct embedding a PyTypeObject after fec1611e9f42c1f0a13eb33474df2ed8ee480842. Remove that and make the types equvivalent, which allows for removing many reinterpret_casts. SbkObjectType is left as a typedef for client code snippets. [ChangeLog][shiboken6] SbkObjectType is now a typedef for PyTypeObject. Task-number: PYSIDE-535 Change-Id: I44812311ccbbe0988c38e34c47d16f6874f8d1cf Reviewed-by: Christian Tismer <tismer@stackless.com>
* Shiboken: Remove cheating macrosChristian Tismer2021-08-061-1/+1
| | | | | | | | | | | | | | | There are a number of cheating macros that allow to use the same code in Python 2 and 3. Because Python 2 is gone, remove these macros. This conversion was partially difficult since certain types collapsed in the XML files and generated functions contained substrings of the macros. This is actually the fourth attempt. Task-number: PYSIDE-1019 Pick-to: 6.1 Change-Id: I116877afc8aa36f4710a40df1769f600b6b750ea Reviewed-by: Christian Tismer <tismer@stackless.com>
* PySide6: Refactor snippet helper retrieveObjectName()Friedemann Kleint2021-07-271-13/+14
| | | | | | | | | There were 2 versions of the helper, one returning QString and the other QByteArray. Use the QByteArray version to save conversions. Pick-to: 6.1 Change-Id: Ibd0038f016c13535018dd4624db29cc4c0ddc824 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide6: Fix QMenu.exec_()Friedemann Kleint2021-07-201-2/+2
| | | | | | | | | | | The return type conversion was broken. Amends 62acb997f7fce1ae922e3a9995272c78353048b9. Pick-to: 6.1 Fixes: PYSIDE-1625 Change-Id: Ib83c363bee4a3c3de4008fdbf6e175093ef3a872 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Enable the exec() functionsCristian Maureira-Fredes2021-05-041-0/+52
| | | | | | | | | | | With Qt6, PySide dropped support for Python 2.7, thus it does not make sense to keep our exec_() renaming inplace. This patch will enable the exec() functions, and adds a deprecation note for exec_(), which will enable us to safely remove it in the future. Change-Id: I7375e10632e7ab534ca264304a5a65f380b9b1bb Reviewed-by: Christian Tismer <tismer@stackless.com>
* Remove const_cast<char *> which are no longer needed in Python 3Friedemann Kleint2021-03-151-10/+4
| | | | | | | | Remove from code as well as from the generator. Change-Id: Ia863788bfa57d52258836c1cbcccb8c9815b7421 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* PySide6: Move injected code snippets where they belongFriedemann Kleint2021-03-101-14/+0
| | | | | | | | Adapt to the restructuring in Qt 6. Change-Id: I3cd65b8ee428fcc75de010efaa3595664a00eb97 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide6: Brush up the injected code snippets and templatesFriedemann Kleint2021-03-101-18/+16
| | | | | | | | | | | - Use qsizetype (or equivalent Py_ssize_t) for containers - Introduce some auto - Use constData() for QByteArray - Use Qt 5 connection syntax - Use nullptr Change-Id: Ie9134a4f756219d6e5c5710ab64c09a236febd4d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Rename PySide2 to PySide6Friedemann Kleint2020-11-021-0/+663
Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I845f7b006e9ad274fed5444ec4c1f9dbe176ff88 Reviewed-by: Christian Tismer <tismer@stackless.com>