How to add tooltip to (main) menu item ?
-
How to add tooltip to (main) menu item ?
The attached , under construction code , should add
BluetoothMenu_Terminal->setToolTip(text);
and it should show up when mouse is above / hovers above selected menu.It does not.
It shows up when the main menu is selected / highlighted and mouse hovers over highlighted submenu.
Both main menu and its submenus should have its own tool tip.
Where is my code error ?
Any help would be appreciated.
{ // Jan3 add menu terminal // Apr2 changed menu text QMenu *BluetoothMenu_Terminal = menuBar()->addMenu(tr("&Terminal ...")); // tool tip shows up in submenu ??? text = " primary parent menu access to terminal and its sub submenus "; BluetoothMenu_Terminal->setToolTip(text); // primary parent menu access to sub submenus //QMenu *BluetoothMenu_Terminal_Primary = // submenu ?? ?? wrong deleted // BluetoothMenu_Terminal->addMenu("serial terminal (modigied orignal code ) (index 40 )... "); int MS_Menu_Index = 40; QAction *submenu_array[100]; // add submenu "action" submenu_array[MS_Menu_Index] = BluetoothMenu_Terminal->addAction(tr("Basic terminal (orignal code ) (40) "), this, [this,MS_Menu_Index]()->void{menu_slot_indexed(MS_Menu_Index);}); submenu_array[MS_Menu_Index]-> setCheckable(true); /// add ?? submenu_array[MS_Menu_Index]-> setCheckable(true); // submenu_array[MS_Menu_Index] text = " Tool tip Basic terminal (orignal code ) (40) "; submenu_array[MS_Menu_Index]->setToolTip(text); #ifdef TRACK_INDEX text = Q_FUNC_INFO; text += " @ line "; text += QString::number(__LINE__); text += " TASK Debug BT serial connnection .. "; //text += QString::number(index); qDebug() << text;// t = " DEBUG serial connection "; #endif MS_Menu_Index = 41; submenu_array[MS_Menu_Index] = //QAction *aboutAct_submenu_index_10 = BluetoothMenu_Terminal->addAction(tr("Bluetooth modified terminal (41) "), this, [this,MS_Menu_Index]()->void{menu_slot_indexed(MS_Menu_Index);}); submenu_array[MS_Menu_Index]-> setCheckable(true); #ifdef BYPASS // this is sub submenuU //submenu_array[MS_Menu_Index] = //QAction *aboutAct_submenu_index_10 = BluetoothMenu_Terminal_Primary->addAction(tr("Indexed submenus hcitool dev ...(40) "), this, [this,MS_Menu_Index]()->void{menu_slot_indexed(MS_Menu_Index);}); #endif }
-
C Christian Ehrlicher moved this topic from Qt Creator and other tools on
-
@AnneRanch UPDATE
Adding
BluetoothMenu_Terminal->setToolTipsVisible(true);to main menu code (!)
makes submenu tool tips work correctlyI am not convinced if there is a way to make the tool tip work on main menu.
Hovering on main menu "pulls down " the submenus and that MAY be stopping / masking the main menu tool tip .I can check that (theory / guess ) by having menu with NO SUBMENUS....
QMenu *BluetoothMenu_Terminal = menuBar()->addMenu(tr("&Terminal ...")); // tool tip shows up in submenu ??? text = " primary parent menu access to terminal and its sub submenus "; BluetoothMenu_Terminal->setToolTip(text); BluetoothMenu_Terminal->setToolTipsVisible(true);