Results 1 to 4 of 4

Thread: Right-click popup from a QListbox

  1. #1
    Join Date
    Jun 2007
    Posts
    21
    Thanks
    25
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Right-click popup from a QListbox

    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.
    Last edited by nleverin; 1st November 2007 at 06:31.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Right-click popup from a QListbox

    Reimplement the context menu event handler of QListBox, not main window.
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    nleverin (2nd November 2007)

  4. #3
    Join Date
    Jun 2007
    Posts
    21
    Thanks
    25
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Right-click popup from a QListbox

    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.

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Right-click popup from a QListbox

    Try following these instructions: Creating Custom Widgets
    J-P Nurmi

  6. The following user says thank you to jpn for this useful post:

    nleverin (7th November 2007)

Similar Threads

  1. Double Click Capturing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2011, 14:12
  2. QGraphicsScene Click / Double Click
    By philentropist in forum Qt Programming
    Replies: 1
    Last Post: 9th February 2007, 04:32
  3. Can't close my popup
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 11th July 2006, 09:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.