[PyQt] QTableWidget - pyuic does not compile several attributes
Hans-Peter Jansen
hpj at urpla.net
Thu Jul 28 14:25:05 BST 2011
On Thursday 28 July 2011, 02:58:38 Protopia wrote:
> I am not sure whether anyone has found this problem before, however I
> can't find it in the archives on Gmane.
>
>
>
> I first came across this problem when I designed a table in QT
> Designer, and set fonts on certain cells. But when I ran the code, no
> formatting. Looking at the code generated by pyuic I could not see
> the code I would expect to set the fonts.
>
>
>
> So, I generated a test UI file in Designer with all properties on the
> table widget, the vertical and horizontal titles and cells themselves
> (attached)
>
>
>
> And then I ran the compiler and looked at the code (attached) and
> found the following things missing:
>
>
>
> QTableWidget:
>
> 1. .font.Kerning not compiled.
>
> 2. .font.Antialiasing not compiled
>
> 3. .QTableView.sortingEnabled is placed in reTranslateUI -
> however this does not seem to be concerned with internationalisation
> and I feel should be in the main code (though I could easily be wrong
> here)
>
> 4. .QTableWidget.rowCount & .columnCount - if these are specified
> explicitly in QT Designer then they appear twice in the .py file. (Of
> course this won't cause major problems, but is nevertheless
> inappropriate.)
>
>
>
> QTableWidgetItem
>
> 1. Horizontal and Vertical header tooltips, whatsthis, fonts,
> textalign, background and foreground are not compiled at all.
>
> 2. Cell tooltips, whatsthis, fonts and textalign are not compiled
> at all.
>
> 3. Cell background and foreground are compiled, however sequence
> of statements is wrong - sets brush twice, then assigns second
> definition to both background and foreground.
First of all, what are you trying to archive?
In order to breathe life into these objects, you need to add some code,
generated by yourself (brain and all..). Designers output is a suitable
basement for this task (in terms of subclassing or calling into), but
in no way it's meant to be exhaustive.
If you question the output of pyuic4, the very next thing to do is
comparing it with the output of uic. Since that is the reference
implementation for pyuic4, any significant differences should be dealt
with, and I guess, if nobody jumps up and provide patches, Phil will
sometime (depending on his priorities and importance..).
> Whilst we are looking at this code, it would also be helpful if we
> were to leave a blank line between code for QTableWidget, Horizontal
> Headers, Vertical Headers and Cells.
Since pyuic4 output is not meant for human consumption (apart from
debugging purposes), a patch from you in this area is highly unlikely
to be applied by Phil.. [Hint: sed is your friend for such tasks]
Pete
More information about the PyQt
mailing list