Hi Matt,

this looked also weird for me (I made these features) and I was tempted
to change the centralWidget to a property, but we decided to stay
compatible with the Qt documentation, where you can find this as normal
getter and setter functions.

I hope this changes sometimes soon. There is also some effort to
support this information in the Qt for Python docs.

What you can do immediately:

Use the pyi generator with true_property and snake_case enabled.
Then you get the properties listed in QtCore.pyi etc.

  <your-bin-folder>/pyside6-genpyi all --feature snake_case \
                                                 true_property

Cheers -- Chris


On 20.11.22 02:50, Matt Milner wrote:
Hi all,

I have been attempting to port a small app from PyQt6 to PySide6, in part in order to use the more pythonic syntax enabled recently by:

from __feature__ import true_property, snake_case

Changing the syntax took a while but was eventually sorted. However, running the program resulted in a window appearing with the correct name but no widgets whatsoever. Diagnosing the issue took me quite a while but in the end I figured out that to set the layout of a widget and then make it the central widget it is apparently required to write:

class MainWindow(QMainWindow):
     def __init__(self):
         super().__init__()
...
         main_layout = QVBoxLayout()
layout_widget = QWidget()
         layout_widget.set_layout(main_layout)
         self.set_central_widget(layout_widget)

However, given that setter/getter methods of the form setText(info) has become set_text = info, I expected the syntax for setting a layout or central widget to be analogous i.e.:
...
         layout_widget.layout = main_layout
         self.central_widget = layout_widget

Is this intended behaviour or an oversight? If intended, why should setting a layout/widget be different to setting text or setting a widget to be enabled?

Kind regards,

Matt

_______________________________________________
PySide mailing list
PySide@qt-project.org
https://lists.qt-project.org/listinfo/pyside

--
Christian Tismer-Sperling    :^)   tis...@stackless.com
Software Consulting          :     http://www.stackless.com/
Strandstraße 37              :     https://github.com/PySide
24217 Schönberg              :     GPG key -> 0xFB7BEE0E
phone +49 173 24 18 776  fax +49 (30) 700143-0023

_______________________________________________
PySide mailing list
PySide@qt-project.org
https://lists.qt-project.org/listinfo/pyside

Reply via email to