注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

沙漠里de烟雨

原创分享,禁止转载

 
 
 

日志

 
 

Qt---QListview中右键菜单及其子菜单项的二级菜单  

2013-12-29 17:15:41|  分类: QT5.x与QML |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
void PriceDisplayBoardWindowBox::mousePressEvent(QMouseEvent * event)
{
if (event->button() == Qt::RightButton)
{
QMenu * popupMenu = new QMenu(this);
QString menuStyle = "QMenu { font-size:18px; color:white; background-color:qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #cccccc, stop: 1 #555555);}" ;
popupMenu->setStyleSheet(menuStyle);

popupMenu->addAction(tr("&Order"), this, SLOT(Order()),QKeySequence(Qt::CTRL + Qt::Key_O));
popupMenu->addAction(tr("&Chart"),this,SLOT(Chart()),QKeySequence(Qt::CTRL + Qt::Key_C));
popupMenu->addSeparator();
popupMenu->addAction(tr("&Delete"),this,SLOT(Delete()),QKeySequence(Qt::CTRL + Qt::Key_D));
popupMenu->addAction(tr("&Add"),this,SLOT(Add()),QKeySequence(Qt::CTRL + Qt::Key_A));
popupMenu->addAction(tr("&Move&Up"),this,SLOT(MoveUp()),QKeySequence(Qt::CTRL + Qt::Key_M,Qt::CTRL + Qt::Key_U));
popupMenu->addAction(tr("&UpTo&Top"),this,SLOT(UpToTop()),QKeySequence(Qt::CTRL + Qt::Key_U,Qt::CTRL + Qt::Key_T));
popupMenu->addAction(tr("&Move&Down"),this,SLOT(MoveDown()),QKeySequence(Qt::CTRL + Qt::Key_M,Qt::CTRL + Qt::Key_D));
popupMenu->addAction(tr("&DownTo&Bottom"),this,SLOT(DownToBottom()),QKeySequence(Qt::CTRL + Qt::Key_D,Qt::CTRL + Qt::Key_B));
popupMenu->addSeparator();
QAction* highestLowest = new QAction(tr("&HighestLowest"), this);
connect(highestLowest,SIGNAL(triggered()), this, SLOT(HighestLowest()));
QAction* preClose = new QAction(tr("&PreClose"), this);
connect(preClose,SIGNAL(triggered()), this, SLOT(PreClose()));
QAction* interestRate = new QAction(tr("&InterestRate"), this);
connect(interestRate,SIGNAL(triggered()), this, SLOT(InterestRate()));
QActionGroup* infoGroup = new QActionGroup(this);
infoGroup->addAction(highestLowest);
infoGroup->addAction(preClose);
infoGroup->addAction(interestRate);
QMenu* marketInfo = popupMenu->addMenu(tr("&MarketInformations"));
marketInfo->addAction(highestLowest);
marketInfo->addAction(preClose);
marketInfo->addAction(interestRate);

popupMenu->exec(event->globalPos());
}
}
  评论这张
 
阅读(1099)| 评论(0)
推荐

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017