Adding item to toolbar context menu
Is there a way to add an item to the context menu that is used for showing/hiding QDockWidgets and QToolbars. I have a widget that I don't think makes sense as either of these that I would like to hide/show using this menu.
Added an Action to your context menu connected to a slot of your QMainWindow where you can call void removeDockWidget ( QDockWidget * dockwidget ) or void removeToolBar ( QToolBar * toolbar )
The widget is neither a dockwidget nor a toolbar.
where the widget is inserted? inside of a QLayout? (QLayout has a removeWidget(QWidget*) )
did you tried QWidget::setVisible ( bool visible ) method?
What I don't know how to do is add something to the applications built in context menu
You can reimplement "QMainWindow::createPopupMenu()":http://doc.qt.nokia.com/latest/qmainwindow.html#createPopupMenu and return your own menu. Alternatively, you can add to the existing context menu and return that one. For example:
class MainWindow : public QMainWindow
QDockWidget *dock1 = new QDockWidget(this);
QToolBar *tool = new QToolBar(this);
QMenu* createPopupMenu ()
QMenu *menu = QMainWindow::createPopupMenu();
menu->addAction("An added action");
int main(int argc, char** argv)
QApplication app(argc, argv);
Does this give you what you need?
Thanks sigrid, that looks like what I'm looking for.
Is it possible to add items to the taskbar context menu? I am referring
to the menu produced when right clicking on the time within Windows XP
(ie "Toolbars" to Properties").
I want to add items onto this menu, but have not found a guide on how to
do this yet (I expect there is a registry entry required to do this). I
would either like to add items to this menu or edit the existing items
on the menu.
Does anyone know how to do this?
It is not possible to add items to the taskbar context menu using Qt.