PDA

View Full Version : QPopupMenu with 2 columns



raphaelf
5th October 2006, 15:11
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?



Q3PopupMenu* contextMenu = new Q3PopupMenu( this );

if( Item )
contextMenu->popup( point );
Q_CHECK_PTR( contextMenu );

{
contextMenu->insertItem( "&add", this, SLOT(addTo()) );
contextMenu->exec( QCursor::pos() );
delete contextMenu;
return;
}


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

Thanks

wysota
5th October 2006, 17:01
Why don't you use a submenu for that?

raphaelf
6th October 2006, 06:23
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



Q3PopupMenu* contextMenu = new Q3PopupMenu( this);
Q3PopupMenu* contextMenu2 = new Q3PopupMenu( this);

contextMenu2->addAction( "&Playlist1", this, SLOT(addToPlaylist()) );
contextMenu2->addAction( "&Playlist2", this, SLOT(addToPlaylist()) );

contextMenu->addMenu("add");
contextMenu->addMenu(contextMenu2);
contextMenu->exec( QCursor::pos() );

raphaelf
9th October 2006, 11:55
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



Q3PopupMenu* contextMenu = new Q3PopupMenu( this);
Q3PopupMenu* contextMenu2 = new Q3PopupMenu( this);

if( Item )
contextMenu->popup( point );

Q_CHECK_PTR( contextMenu );

contextMenu2->addAction( playlistname, this, SLOT(addToPlaylist()) );
contextMenu->addMenu(contextMenu2);

contextMenu->exec( QCursor::pos() );

raphaelf
11th October 2006, 06:02
Can somebody help me? :crying:

munna
11th October 2006, 07:41
Try this:




Q3PopupMenu* contextMenu = new Q3PopupMenu( this);
Q3PopupMenu* contextMenu2 = new Q3PopupMenu( this);
contextMenu2->setTitle("Your Title");
if( Item )
contextMenu->popup( point );

Q_CHECK_PTR( contextMenu );
contextMenu2->addAction( playlistname, this, SLOT(addToPlaylist()) );
contextMenu->addMenu(contextMenu2);
contextMenu->exec( QCursor::pos() );

raphaelf
11th October 2006, 10:06
Hi :)

It works!!

thank you