zoukankan      html  css  js  c++  java
  • Qt creator 创建鼠标右键菜单 (不新建类)

    界面

    步骤

    1.  打开你的界面文件并选中你要添加右键的控件,选择“CustomContextMenu”

    2. 右键选择“转到槽...” -> customContextMenuRequested
    3. 插入下面代码即可
      void MainWindow::on_listWidget_customContextMenuRequested(const QPoint &pos)
      {
          static QMenu *qMenu = NULL;
          if (qMenu == NULL)
          {
              qMenu = new QMenu(ui->listWidget);
              QAction* closePaneAction = new QAction("&Close",this);
              connect(closePaneAction, SIGNAL(triggered()), this, SLOT(close()));
      
              qMenu->addAction(closePaneAction);
          }
      
          qMenu->exec(QCursor::pos()); //在鼠标点击的位置显示鼠标右键菜单
      }
      

        

  • 相关阅读:
    SQL操作符的优化
    Oracle 模糊查询 优化
    Mysql中的语句优化
    SQL优化
    Pro Git读书笔记
    前端工程化
    前端工程化
    前端工程化
    前端工程化
    前端工程化
  • 原文地址:https://www.cnblogs.com/sollyu/p/3680920.html
Copyright © 2011-2022 走看看