开发者

How can I get this kind of dropdown with Qt? (Specifically PyQt4)

This is the type of 开发者_如何学运维dropdown window I would like. It has columns, with different types of data in each. I tried just using tab delimiting, but it made it look sloppy. How could I get a dropdown / combobox element like this using PyQt4? (Ignore the black box, I just wanted to hide my system files).

How can I get this kind of dropdown with Qt? (Specifically PyQt4)


By using your own custom item delegate. Probably not easy answer one would hope for, but you will have complete control :)

See http://doc.trolltech.com/4.6/model-view-delegate.html


I've not used PyQt, but if it's anything like PyGTK, it's possible to use something like the tree widget.

Although as an alternative, you could simply use string formatting (much better than tab delimiting):

(new style formatting)

'{0:20}{0:20}'.format('l','lines in current document')

And if you want to make sure there's enough for each of the largest you could do something like this:

leftwidth = len(max(['l', 'foo', 'longitem'], key=len))
rightwidth = len(max(['Number of lines', 
                      'some other option', 
                      'yet another long option'], key=len))

'{key:{L}}{desc:{R}}'.format(key='l',desc='Number of lines',
                             L=leftwidth, R=rightwidth)

And if you store your key/description in a dictionary it's even easier to automate the process.


Absolutely, u must use QColumnView, it is extended version of Listview or just multiple listview. As you know, listview is opened version of Combobox.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜