引用第1楼duduqq于2009-06-04 17:47发表的 :
你让菜单一显示出来又Delete了
dodoqq 帮忙看看这是什么错误??
void PixmapTest::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = createStandardContextMenu();
QList<QAction *> actList = menu->actions();
actList[UndoAct]->setText(QString::fromLocal8Bit("撤销(&U)"));
actList[RedoAct]->setText(QString::fromLocal8Bit("重复(&R)"));
actList[CutAct]->setText(QString::fromLocal8Bit("剪切(&T)"));
actList[CopyAct]->setText(QString::fromLocal8Bit("复制(&C)"));
actList[PasteAct]->setText(QString::fromLocal8Bit("粘帖(&P)"));
actList[ClearAct]->setText(QString::fromLocal8Bit("删除"));
actList[SelectAllAct]->setText(QString::fromLocal8Bit("全选"));
//...
menu->exec(event->globalPos());
delete menu;
}
这段代码报错如下:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pixmaptest.cpp
.\pixmaptest.cpp(356) : error C3861: 'createStandardContextMenu': identifier not found
.\pixmaptest.cpp(359) : error C2065: 'UndoAct' : undeclared identifier
.\pixmaptest.cpp(359) : error C2227: left of '->setText' must point to class/struct/union/generic type
.\pixmaptest.cpp(360) : error C2065: 'RedoAct' : undeclared identifier
.\pixmaptest.cpp(360) : error C2227: left of '->setText' must point to class/struct/union/generic type
.\pixmaptest.cpp(361) : error C2065: 'CutAct' : undeclared identifier
.\pixmaptest.cpp(361) : error C2227: left of '->setText' must point to class/struct/union/generic type
.\pixmaptest.cpp(362) : error C2065: 'CopyAct' : undeclared identifier
.\pixmaptest.cpp(362) : error C2227: left of '->setText' must point to class/struct/union/generic type
.\pixmaptest.cpp(363) : error C2065: 'PasteAct' : undeclared identifier
.\pixmaptest.cpp(363) : error C2227: left of '->setText' must point to class/struct/union/generic type
.\pixmaptest.cpp(364) : error C2065: 'ClearAct' : undeclared identifier
.\pixmaptest.cpp(364) : error C2227: left of '->setText' must point to class/struct/union/generic type
.\pixmaptest.cpp(365) : error C2065: 'SelectAllAct' : undeclared identifier
.\pixmaptest.cpp(365) : error C2227: left of '->setText' must point to class/struct/union/generic type