Results 1 to 7 of 7

Thread: QPopupMenu with 2 columns

  1. #1
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Red face QPopupMenu with 2 columns

    Hi everybody,
    QT:4.1.3
    OS: WIN
    Compiler: MINGW
    I was able to create a menu.
    But i need to create a popupmenu with 2 columns.
    The first column i need "add to". And the 2. Column i need to insert values from a database.
    Its possible to create a popupmenu qith 2 columns?

    Qt Code:
    1. Q3PopupMenu* contextMenu = new Q3PopupMenu( this );
    2.  
    3. if( Item )
    4. contextMenu->popup( point );
    5. Q_CHECK_PTR( contextMenu );
    6.  
    7. {
    8. contextMenu->insertItem( "&add", this, SLOT(addTo()) );
    9. contextMenu->exec( QCursor::pos() );
    10. delete contextMenu;
    11. return;
    12. }
    To copy to clipboard, switch view to plain text mode 

    I need after to get the selected text from the popupmenu (2. Column)

    Thanks
    Think DigitalGasoline

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QPopupMenu with 2 columns

    Why don't you use a submenu for that?

  3. #3
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QPopupMenu with 2 columns

    Hi Wisota,

    I have now a menu and a submenu. But how could i insert the submenu exactly on the first item of of menu:
    add->Playlist1

    Now i have:
    add->
    ->Playlist1

    Qt Code:
    1. Q3PopupMenu* contextMenu = new Q3PopupMenu( this);
    2. Q3PopupMenu* contextMenu2 = new Q3PopupMenu( this);
    3.  
    4. contextMenu2->addAction( "&Playlist1", this, SLOT(addToPlaylist()) );
    5. contextMenu2->addAction( "&Playlist2", this, SLOT(addToPlaylist()) );
    6.  
    7. contextMenu->addMenu("add");
    8. contextMenu->addMenu(contextMenu2);
    9. contextMenu->exec( QCursor::pos() );
    To copy to clipboard, switch view to plain text mode 
    Think DigitalGasoline

  4. #4
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QPopupMenu with 2 columns

    Hi,
    I have to menus.I can see both.
    But i have just ">". How could i insert a text there like "add >"?
    Please look my pic.

    Thanks

    Qt Code:
    1. Q3PopupMenu* contextMenu = new Q3PopupMenu( this);
    2. Q3PopupMenu* contextMenu2 = new Q3PopupMenu( this);
    3.  
    4. if( Item )
    5. contextMenu->popup( point );
    6.  
    7. Q_CHECK_PTR( contextMenu );
    8.  
    9. contextMenu2->addAction( playlistname, this, SLOT(addToPlaylist()) );
    10. contextMenu->addMenu(contextMenu2);
    11.  
    12. contextMenu->exec( QCursor::pos() );
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files
    Think DigitalGasoline

  5. #5
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QPopupMenu with 2 columns

    Can somebody help me?
    Think DigitalGasoline

  6. #6
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPopupMenu with 2 columns

    Try this:

    Qt Code:
    1. Q3PopupMenu* contextMenu = new Q3PopupMenu( this);
    2. Q3PopupMenu* contextMenu2 = new Q3PopupMenu( this);
    3. contextMenu2->setTitle("Your Title");
    4. if( Item )
    5. contextMenu->popup( point );
    6.  
    7. Q_CHECK_PTR( contextMenu );
    8. contextMenu2->addAction( playlistname, this, SLOT(addToPlaylist()) );
    9. contextMenu->addMenu(contextMenu2);
    10. contextMenu->exec( QCursor::pos() );
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to munna for this useful post:

    raphaelf (11th October 2006)

  8. #7
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Talking Re: QPopupMenu with 2 columns

    Hi

    It works!!

    thank you
    Think DigitalGasoline

Similar Threads

  1. Maximize columns on QTableWidget
    By marcelrc in forum Newbie
    Replies: 1
    Last Post: 21st May 2006, 15:34
  2. QCheckListItem with multiple columns?
    By ecphora in forum Qt Programming
    Replies: 7
    Last Post: 12th April 2006, 05:01
  3. Replies: 6
    Last Post: 5th March 2006, 21:05
  4. Changing the order of columns in QTreeView
    By johnny_sparx in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2006, 00:00
  5. Mac OS X Columns have gaps
    By square in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2006, 09:40

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.