[PySide] QtDesigner ???
Paolo De Stefani
paolo at paolodestefani.it
Wed Apr 27 19:39:07 CEST 2022
So this can be considered a pyside6 rel. 6.3 bug ?
Il 27/04/2022 16:52 David Ching ha scritto:
> Hi Paolo,
>
> I again tried your original code, and this time got an error:
>
> c:\Src\paolo_orig>python pyDBManager.py
> Traceback (most recent call last):
> File "c:\Src\paolo_orig\pyDBManager.py", line 166, in <module>
> window = MainWindow()
> File "c:\Src\paolo_orig\pyDBManager.py", line 61, in __init__
> self.ui.setupUi(self)
> File "c:\Src\paolo_orig\Ui\DBManagerMainWindowBad.py", line 246, in
> setupUi
> self.tab_widget.setCurrentIndex(3)
> AttributeError: 'PySide6.QtWidgets.QSpacerItem' object has no attribute
> 'hasHeightForWidth'
>
>
> I had rebuilt your code by editing your batch file to fix directories
> on my
> system and ran it. This runs uic and rcc. I diffed the results with
> yours.
> Earlier I had missed differences in the generated
> "UI\DBManagerMainWindowBad.py" in line 246:
>
> Yours: self.tab_widget.setCurrentIndex(3)
> Mine: self.tab_widget.setCurrentIndex(0)
>
> I don't know why the generated file was different; perhaps because I am
> using 6.2 tool and you are using 6.3. But, when I changed mine to be
> like
> yours, I got the same error.
>
> Having reproduced your issue, I tried moving the snake_case enabling
> before
> and after the import of the generated code, and it made no difference,
> i.e.
> there was an error with both:
>
> from Ui.DBManagerMainWindowBad import Ui_DBManagerMainWindow
> from __feature__ import snake_case, true_property
>
> and
>
> from __feature__ import snake_case, true_property
> from Ui.DBManagerMainWindowBad import Ui_DBManagerMainWindow
>
>
> Since that failed, I disabled snake_case --- I verify with you that it
> fixes
> it!
>
> I commented out
> #from __feature__ import snake_case, true_property
>
> And to avoid Atttribute errors at runtime, changed the necessary calls
> to
> methods of the "self.ui.xxx" widgets to use camelCase e.g.
> #self.ui.status_bar.add_permanent_widget(self.status_log)
> self.ui.status_bar.addPermanentWidget(self.status_log)
>
> Then it worked --- there does seem to be an error in generated code if
> snake
> case is enabled.
>
> Thanks,
> David
>
> -----Original Message-----
> From: Paolo De Stefani <paolo at paolodestefani.it>
> Sent: Tuesday, April 26, 2022 11:04 AM
> To: David Ching <dc at dcsoft.com>
> Cc: pyside at qt-project.org
> Subject: Re: [PySide] QtDesigner ???
>
> I also noted that the error message is different if a modify the
> generated
> pyDBManagerMainWIndowBad.py the original error is:
>
> C:\PyWare\pyDBManager\Bug>python pyDBManager.py Traceback (most recent
> call
> last):
> File "C:\PyWare\pyDBManager\Bug\pyDBManager.py", line 161, in
> <module>
> window = MainWindow()
> File "C:\PyWare\pyDBManager\Bug\pyDBManager.py", line 56, in
> __init__
> self.ui.setupUi(self)
> File "C:\PyWare\pyDBManager\Bug\DBManagerMainWindowBad.py", line
> 133, in
> setupUi
> self.gridLayout.setContentsMargins(0, 0, 0, 0)
> AttributeError: 'PySide6.QtWidgets.QGridLayout' object has no attribute
> 'setContentsMargins'. Did you mean: 'getContentsMargins'?
>
> If i add even an import line like import os and run again the script
> the
> error message is:
>
> C:\PyWare\pyDBManager\Bug>python pyDBManager.py Traceback (most recent
> call
> last):
> File "C:\PyWare\pyDBManager\Bug\pyDBManager.py", line 161, in
> <module>
> window = MainWindow()
> File "C:\PyWare\pyDBManager\Bug\pyDBManager.py", line 56, in
> __init__
> self.ui.setupUi(self)
> File "C:\PyWare\pyDBManager\Bug\DBManagerMainWindowBad.py", line 30,
> in
> setupUi
> if not DBManagerMainWindow.objectName():
> AttributeError: 'MainWindow' object has no attribute 'objectName'. Did
> you
> mean: 'object_name'?
>
> Why this behaviour ???
> But looks like direct linked to the snake_case option
--
Paolo De Stefani
More information about the PySide
mailing list