[PyKDE] context menu in QHeader

Boudewijn Rempt boud at valdyas.org
Wed Apr 17 20:22:41 BST 2002


On Wednesday 17 April 2002 07:54, Andrew Dalke wrote:

>
> That all said, how do I support creating a context pop-up menu from
> the QHeader?

Right, kids are in bed. I should be studying for my java exam, but anyway.

QHeader inherits QWidget, which has a method, mousePressEvent(QEvent ev).
You can find out which kind of press occurred, and also the location of the 
press. From there, it's easy to instantiate and populate a QPopupMenu.

Keep in mind that signals/slots are meant for communication between objects. 
Events are meant for the handling of user input -- key presses, mouse stuff,
things like that.

Have you seen

http://www.opendocspublishing.com/pyqt/index.lxp?lxpwrap=x2629%2ehtm#AEN2679

and

http://www.opendocspublishing.com/pyqt/index.lxp?lxpwrap=c1267%2ehtm

where I discuss events?

In the end, it's very simple...

As for the rest: QGrid isn't a widget, but a layout manager, actually. For 
your purpose, QTable should work best. If you want in-place editing, then
QListView might work, too -- it can handle a lot of data, actually. But QTable 
was designed for large spreadsheet type applications -- the doc speaks of one 
million by one million cells, which should be ample. More, and your users 
might get lost.

 If you mean QGridView instead of QGrid -- that's a possibility, but it isn't 
easy to use that class. You will have to provide your own painting code, for 
instance.

-- 
Boudewijn Rempt | http://www.valdyas.org





More information about the PyQt mailing list