PDA

View Full Version : Right-click popup from a QListbox



nleverin
1st November 2007, 04:32
Hi can anyone help me with the best way to generate a popup window inside a Qlistbox when an operator right clicks within the Qlistbox area. (using Qt3)

i have implemented by Qlistbox in the designer, and when using the code

void bla::contextMenuEvent(QContextMenuEvent *event)
{
QPopuMenu contextMenu(this)
contextMenu.exec(event->globalPos());
}

in my subclass i can get the popup menu to appear anywhere in the mainwindow i just cannot get it to only come up within the qlistbox object.

i have replaced the 'this' pointer with the name of my qlistbox object name but still it brings up the popup menu any where on my main dialog.

any help will be very appreciated, thanks in advance,

nlev.

jpn
1st November 2007, 13:27
Reimplement the context menu event handler of QListBox, not main window.

nleverin
2nd November 2007, 03:36
Hi Jpn,

thanks for the reply.

Because i have implemented my qlistbox in the designer does this mean that i would have to Reimplement the context menu event handler of QListBox, in a subclass of qlistbox and then create a custom widget that uses this this new reimplemented qlistbox within the designer?

cheers,
nlev.

jpn
2nd November 2007, 08:59
Try following these instructions: Creating Custom Widgets (http://doc.trolltech.com/3.3/designer-manual-7.html)