[PyQt] Strange bug in PyQt

Andreas Pakulat apaku at gmx.de
Sat Aug 9 23:09:46 BST 2008


On 09.08.08 18:12:12, Roberto Alsina wrote:
> On Saturday 09 August 2008 15:57:01 Andreas Pakulat wrote:
> > On 09.08.08 14:09:17, Roberto Alsina wrote:
> > > On Saturday 09 August 2008 09:40:31 Andreas Pakulat wrote:
> > > > On 08.08.08 19:42:19, Roberto Alsina wrote:
> > > > > On Friday 08 August 2008 18:43:12 Andreas Pakulat wrote:
> > > > > > On 08.08.08 16:36:35, Roberto Alsina wrote:
> > > > > > > I don't know how to explain it, si I have to use pictures.
> > > > > >
> > > > > > Are you talking about the cut-off menu items? Or what? Which parts
> > > > > > of the pictures should we look into/
> > > > >
> > > > > Cutoff menu items, varying font sizes, the "Search" label, even the
> > > > > left qtreeview's header is weird.
> > > > >
> > > > > Loos like font metrics were all cray.
> > > >
> > > > Hmm, can you produce a small example that demonstrates the problem? Its
> > > > quite weird that loading an icon in a different way has such an effect.
> > > > I'm suspecting a bit that this might be an issue on your machine, so it
> > > > would be good to test it on other machines/different setups.
> > >
> > > Attached is an example, and it got even weirder.
> > >
> > > 1) It doesn't depend on actually using the QIcon, only on creating it
> > > before there's a QApplication.
> >
> > Thats a bug in your application, Qt doesn't support doing much - if
> > anything at all - with it until a QApp is created.
> 
> Sure, but it's a bug that should give an error instead of messing the UI :-)
> 
> > > 2) On windows you can't do that. (gives an error "Must construct a
> > > QApplication before a QPaintDevice" which looks reasonable to me) [Qt
> > > 4.4.1]
> > >
> > > 3) On Arch Linux I get cutoff menus and small fonts on the QTreeView
> > > [4.4.1]
> >
> > Indeed. I can confirm the problem, however it only appears with the
> > complete example. Just using a static QIcon before creating a QApp
> > doesn't produce it (i.e. just creating a mainwindow and adding a few
> > menus is not triggering the problem). So I can just guess its got
> > something to do with the icon + .ui file.
> 
> I tested it with several different SVG icons and the behaviour is the same.
> 
> The UI file is created with designer, just a menu with three items and a 
> treewidget, no properties set on anything.
> 
> > I also noticed that Qt and PyQt bail out if you use actual files in the
> > filesystem, as opposed to resources.
> 
> That's interesting.
> 
> I am leaning now towards believing it's a unix-specific Qt bug and not a PyQt 
> bug. I should do a C++ project to test it (ugh)

Here are some more observations:

- loading the .svg from the disk also breaks the ui, so you can leave
  out the .qrc stuff - one component less that could be the cause
- as I said before one needs to use a .ui file and apparently it needs
  to have a QAbstractItemView in the mainwindow, without it its also not
  showing the problem.

So alltogether attached is a c++ app that reproduces the problem, feel
free to use that when sending a bugreport to TT. (the main.cpp and .ui
file can just be placed into an empty dir and then qmake
-project;qmake;make can be run to build the app)

Andreas

-- 
A day for firm decisions!!!!!  Or is it?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 490 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080809/69e8e69a/main.bin
-------------- next part --------------
<ui version="4.0" >
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow" >
  <property name="geometry" >
   <rect>
    <x>0</x>
    <y>0</y>
    <width>800</width>
    <height>600</height>
   </rect>
  </property>
  <property name="windowTitle" >
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget" >
   <property name="geometry" >
    <rect>
     <x>0</x>
     <y>27</y>
     <width>800</width>
     <height>549</height>
    </rect>
   </property>
   <layout class="QGridLayout" name="gridLayout" >
    <item row="0" column="0" >
     <widget class="QTableView" name="treeView" />
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menubar" >
   <property name="geometry" >
    <rect>
     <x>0</x>
     <y>0</y>
     <width>800</width>
     <height>27</height>
    </rect>
   </property>
   <widget class="QMenu" name="menuDoo" >
    <property name="title" >
     <string>Doo</string>
    </property>
    <addaction name="actionNfd" />
   </widget>
   <widget class="QMenu" name="menuBar" >
    <property name="title" >
     <string>Bar</string>
    </property>
   </widget>
   <addaction name="menuDoo" />
   <addaction name="menuBar" />
  </widget>
  <widget class="QStatusBar" name="statusbar" >
   <property name="geometry" >
    <rect>
     <x>0</x>
     <y>576</y>
     <width>800</width>
     <height>24</height>
    </rect>
   </property>
  </widget>
  <action name="actionNfd" >
   <property name="text" >
    <string>nfd</string>
   </property>
  </action>
 </widget>
 <resources/>
 <connections/>
</ui>


More information about the PyQt mailing list