简体   繁体   English

QWidget超过另一个小部件

[英]QWidget over another widget

I have graphs (QCustomPlot) that are arranged vertically with a separator (QSplitter). 我有用分隔符(QSplitter)垂直排列的图形(QCustomPlot)。

How can I get the window as in the picture when I click on the right button? 单击右按钮时如何获得如图所示的窗口? I know how to handle the right button signal, but I can not understand how to display the window I need. 我知道如何处理右按钮信号,但我不明白如何显示所需的窗口。

在此处输入图片说明

Add a QMenu as a member of your widget. 将QMenu添加为小部件的成员。 In .h: 在.h中:

#include <QMenu>
#include <QAction>
.....
QMenu menu;

In constructor: 在构造函数中:

QAction* action=new QAction("save",this);
connect(action,SIGNAL(triggered()),this,SLOT(save()));
menu.addAction(action);
QAction* action2=new QAction("clear",this);
connect(action2,SIGNAL(triggered()),this,SLOT(clear()));
menu.addAction(action2);
setContextMenu(&menu);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM