PDA

View Full Version : where could QPopupMenu show besides QMenuBar !



bigbigmoon
1st November 2006, 01:32
hello everyone :)

I have some problems with QPopupMenu :
source code :
QWidget * tabindex ;
tabindex =new QWidget (this ,"tabindex ") ;
QPopupMenu *home ;
home =new QPopupMenu (tabindex,"home " );
home ->insertItem ("hello world ",-1) ;

but the menu item don't show in tabindex ,must the popupmenu add in QMenuBar :confused:

another question :
The QMenuBar class provides a horizontal menu bar,how I could show menu items like the left column in the menu of XP(double columns menu ) ?

thanks

munna
1st November 2006, 04:36
but the menu item don't show in tabindex ,must the popupmenu add in QMenuBar

you will need to call QPopupMenu::exec() for your popup menu to be shown.

bigbigmoon
1st November 2006, 06:58
Thank you for your reply!;)
I tried it ,
add source code :
home->exec();
and
home->exec(QPoint( 0,58 ) );(the position (0,58 )is relative to the top level widget )
but the menu item is shown out of the geometry of tabindex .?:confused:

if I add code as :
KHistoryCombo *list ;
list =new KHistoryCombo (tabindex ,"hello ") ;
list ->addToHistory ("kcontrol ") ;
the list will be shown in tabindex .

munna
1st November 2006, 07:12
try this




home->exec(parentWidget.mapToGlobal(QPoint( 0,58 ) ));

bigbigmoon
2nd November 2006, 01:03
Thank you for your reply again!
I has used the ffollowing functions :
QWidget::mapFrom ( QWidget * parent, const QPoint & pos ) const
QWidget::mapFromGlobal ( const QPoint & pos ) const
QWidget::mapFromParent ( const QPoint & pos ) const
QWidget::mapTo ( QWidget * parent, const QPoint & pos ) const

but the popupmenu remain showed out of it's parent widget :confused: