[PyKDE] How to display 'multi-line text' with QListViewItem

Phil Thompson phil at river-bank.demon.co.uk
Sun Jun 10 21:21:07 BST 2001


Eiji Katagiri wrote:
> 
> I want to display 'multi-line text' with QListViewItem.
> There is a simple example. In this example, I got the
> incomplete disply. It seems that setHeight() method
> doesn't work. why ?
> 
> --
> 
> #!/usr/bin/env python
> import sys
> from qt import *
> 
> class ListView(QWidget):
>     def __init__(self, *args):
>         apply(QWidget.__init__, (self,)+args)
>         self.setCaption('multi-line')
>         listview = QListView(self, 'listview')
>         listview.addColumn('Contents')
>         item = QListViewItem(listview, '1st line\n2nd line')
>         item.setHeight(40)
>         sz = listview.sizeHint()
>         listview.resize(sz.width(), sz.height())
> 
> a = QApplication(sys.argv)
> w = ListView()
> a.setMainWidget(w)
> w.show()
> a.exec_loop()

Don't know - but the equivalent C++ program behaves in the same way, so
it's not a PyQt problem.

Phil




More information about the PyQt mailing list