raphaelf
11th October 2006, 11:52
Hi everyboby!
I have a Q3PopupMenu for my ListView created.The idea from this Popupmenu is that the user can select a song and
add to a playlist(submenu)
I have a Menu and a Submenu. I generate actions with values from my Database (see code).
For example: playlist1, playlist2, playlist3(actions).
So my actions will everytime generated when the user start my popupmenu. I have a dynamic submenu with dynamic actions.
All my actions call the same function "addToPlaylist()".Thats ok.
Now i must get the selected action text from the submenu.
With QAction->text() i can read the action text. But how could i get the selected text of my popupmenu?Because my action names is everytime the same.
I need this text to be able to insert value on a database.
Have somebody a idea?
Q3PopupMenu* contextMenu = new Q3PopupMenu( this);
Q3PopupMenu* contextMenu2 = new Q3PopupMenu( this);
if( Item )
contextMenu->popup( point );
Q_CHECK_PTR( contextMenu );
if((ui.playlistname_cb->currentText() == "") && (ui.listView->childCount() > 0))
{
QSqlQuery select_playlistname("select playlistname from playlistname_tbl");
while(select_playlistname.next())
{
QString playlistname = select_playlistname.value(0).toString();
contextMenu2->setTitle("add to Playlist");
QAction *action = new QAction(playlistname, this);
connect(action,SIGNAL(activated()),this,SLOT(addTo Playlist()));
contextMenu2->addAction(action );
contextMenu->addMenu(contextMenu2);
QMessageBox::information(this,
("Info"),action->text());
}
contextMenu->exec( QCursor::pos() );
return;
}
I have a Q3PopupMenu for my ListView created.The idea from this Popupmenu is that the user can select a song and
add to a playlist(submenu)
I have a Menu and a Submenu. I generate actions with values from my Database (see code).
For example: playlist1, playlist2, playlist3(actions).
So my actions will everytime generated when the user start my popupmenu. I have a dynamic submenu with dynamic actions.
All my actions call the same function "addToPlaylist()".Thats ok.
Now i must get the selected action text from the submenu.
With QAction->text() i can read the action text. But how could i get the selected text of my popupmenu?Because my action names is everytime the same.
I need this text to be able to insert value on a database.
Have somebody a idea?
Q3PopupMenu* contextMenu = new Q3PopupMenu( this);
Q3PopupMenu* contextMenu2 = new Q3PopupMenu( this);
if( Item )
contextMenu->popup( point );
Q_CHECK_PTR( contextMenu );
if((ui.playlistname_cb->currentText() == "") && (ui.listView->childCount() > 0))
{
QSqlQuery select_playlistname("select playlistname from playlistname_tbl");
while(select_playlistname.next())
{
QString playlistname = select_playlistname.value(0).toString();
contextMenu2->setTitle("add to Playlist");
QAction *action = new QAction(playlistname, this);
connect(action,SIGNAL(activated()),this,SLOT(addTo Playlist()));
contextMenu2->addAction(action );
contextMenu->addMenu(contextMenu2);
QMessageBox::information(this,
("Info"),action->text());
}
contextMenu->exec( QCursor::pos() );
return;
}