一、设置控件
在对应控件的属性中,将contextMenuPolicy设置为CustomContextMenu。
二、添加槽函数
在对应控件上右键选择槽函数customContextMenuRequested(QPoint)。
三、在槽函数中添加右键菜单
在槽函数中输入如下代码,添加右键菜单。
//右键菜单
void MainWindow::on_stackedWidget_customContextMenuRequested(const QPoint &pos)
{
QMenu * menu = new QMenu(this);
QAction *a服务器托管网ction = new QAction;
action->setText(("适应窗口宽度"));
connect(action, SIGNAL(triggered(bool)), this, SLOT(PageZoomToWidth()));
menu->addAction(action);
menu->exec服务器托管网(QCursor::pos());
}
通过connect函数链接右键的处理函数,如下图所示。
//恢复到合适大小
void MainWindow::PageZoomToWidth()
{
//*******************文件打开状态才响应*******************
if (!pdf->hasOpenDocument()) {
return;
}
pdf->zoomCentered(XpdfWidget::zoomToWidth);
}
四、头文件的处理
右键的处理函数需要作为slots,在头文件中定义
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
相关推荐: ARM 版 OpenEuler 22.03 部署 KubeSphere v3.4.0 不完全指南续篇
高春辉、王春生、朱峰:关于开源创业的15件小事 作者:运维有术 前言 知识点 定级:入门级 KubeKey 安装部署 ARM 版 KubeSphere 和 Kubernetes ARM 版 KubeSphere 和 Kubernetes 常见问题 实战服务器配…