[PyQt] QTableWidget - pyuic does not compile several attributes

Phil Thompson phil at riverbankcomputing.com
Thu Jul 28 18:45:40 BST 2011


On Thu, 28 Jul 2011 01:58:38 +0100, "Protopia" <pyqt4 at protopia.co.uk>
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.

Fixed.

> 2.     .font.Antialiasing not compiled

Fixed.

> 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)

This is a side effect of the way i18n support is implemented.

> 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.)

Fixed.

> QTableWidgetItem
> 
> 1.     Horizontal and Vertical header tooltips, whatsthis, fonts,
> textalign, background and foreground are not compiled at all.

Fixed.

> 2.     Cell tooltips, whatsthis, fonts and textalign are not compiled at
> all.

Fixed.

> 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.

Fixed.

> 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.
> 
>  
> 
> Note: I am using python2.7.2 32-bit, and PyQt4.8.4-1 binary
> PyQt-Py2.7-x86-gpl-4.8.4-1.exe.
> 
>  
> 
> P.S. I am trying to look at the uiparser.py and properties.py part of
> the Pyqt4 uic compiler to see if I can work out how to fix this - but as
> yet I have failed to understand the code well enough to work it out.
> 
>  
> 
> Rgds, P

I think QListWidgetItem and QTreeWidgetItem will have similar problems but
I'll look at those tomorrow.

Thanks,
Phil


More information about the PyQt mailing list