• 4952阅读
  • 4回复

qt creator中如何实现右键菜单--类似VS中的contentMenu? [复制链接]

上一主题 下一主题
离线qulu2009
 
只看楼主 倒序阅读 楼主  发表于: 2009-07-16
如题目所示,怎么在qt creator中的listview中实现右键菜单啊,发现没有专用控件啊,不知道怎么弄啊,有高手指导指导吗?
非常感谢啊。。。
离线cx_star

只看该作者 1楼 发表于: 2009-07-17
void MainWindow::createContextMenu()
{
    spreadsheet->addAction(cutAction);
    spreadsheet->addAction(copyAction);
    spreadsheet->addAction(pasteAction);
    spreadsheet->setContextMenuPolicy(Qt::ActionsContextMenu);
}


Any Qt widget can have a list of QActions associated with it. To provide a context menu for the application, we add the desired actions to the Spreadsheet widget and set that widget's context menu policy to show a context menu with these actions. Context menus are invoked by right-clicking a widget or by pressing a platform-specific key.

C++ GUI Programming with Qt 4, Second Edition 第三章中的例子
离线qulu2009
只看该作者 2楼 发表于: 2009-07-17
那请问如何在指定地点出现右键呢?
离线cx_star

只看该作者 3楼 发表于: 2009-07-17
QContextMenuEvent
离线qulu2009
只看该作者 4楼 发表于: 2009-07-18
能说的详细点吗?小弟才接触Qt,迷茫中呢。。。谢谢哈。。。
快速回复
限100 字节
 
上一个 下一个