QT Creator에서 스프레드 시트 응용 프로그램을 실행하려고하는데 오류없이 컴파일되지만 응용 프로그램을 실행하려고하면 다음 오류가 표시됩니다. QWidget::insertAction Attempt to insert null action
. 문제는 어디에서 문제가 발생하는지 알지 못한다는 것입니다 ... 오류는 QT Creator의 오류 섹션에는 나타나지 않지만 프로그램을 실행할 때 생성 된 작은 터미널에 나타나지 않습니다.QWidget :: insertAction 런타임에 null 동작을 삽입하려고 시도했습니다.
헤더에서 초기화 된 모든 동작을 초기화하는 createActions()
함수가 있는데, 거기에서 오는 것일 수 있습니까? 헤더의 민간 부분에
조치는 다음과 같다 :
void MainWindow::createActions()
{
newAction = new QAction(tr("&New"), this);
newAction->setIcon(QIcon(":/images/avatar.jpeg"));
newAction->setShortcut(QKeySequence::New);
newAction->setStatusTip(tr("Create a new spreadsheet file"));
connect(newAction, SIGNAL(triggered()), this, SLOT(newFile()));
for (int i = 0; i < MaxRecentFiles; ++i) {
recentFileActions[i] = new QAction(this);
recentFileActions[i]->setVisible(false);
connect(recentFileActions[i], SIGNAL(triggered()),this, SLOT(openRecentFile()));
}
closeAction = new QAction(tr("&Close"), this);
closeAction->setShortcut(QKeySequence::Close);
closeAction->setStatusTip(tr("Close this window"));
connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
exitAction = new QAction(tr("E&xit"), this);
exitAction->setShortcut(tr("Ctrl+Q"));
exitAction->setStatusTip(tr("Exit the application"));
connect(exitAction, SIGNAL(triggered()),
qApp, SLOT(closeAllWindows()));
selectAllAction = new QAction(tr("&All"), this);
selectAllAction->setShortcut(QKeySequence::SelectAll);
selectAllAction->setStatusTip(tr("Select all the cells in the "
"spreadsheet"));
connect(selectAllAction, SIGNAL(triggered()),
spreadsheet, SLOT(selectAll()));
showGridAction = new QAction(tr("&Show Grid"), this);
showGridAction->setCheckable(true);
showGridAction->setChecked(spreadsheet->showGrid());
showGridAction->setStatusTip(tr("Show or hide the spreadsheet's "
"grid"));
connect(showGridAction, SIGNAL(toggled(bool)),
spreadsheet, SLOT(setShowGrid(bool)));
aboutQtAction = new QAction(tr("About &Qt"), this);
aboutQtAction->setStatusTip(tr("Show the Qt library's About box"));
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
이러한 조치, 생성 된 후 createMenus()
의 메뉴에 추가됩니다 여기
QAction *newAction;
QAction *openAction;
QAction *aboutQtAction;
QAction *closeAction;
QAction *exitAction;
QAction *selectAllAction;
QAction *showGridAction;
QAction *saveAction;
QAction *saveAsAction;
QAction *cutAction;
QAction *copyAction;
QAction *pasteAction;
QAction *deleteAction;
QAction *selectRowAction;
QAction *selectColumnAction;
QAction *findAction;
QAction *goToCellAction;
QAction *recalculateAction;
QAction *sortAction;
QAction *autoRecalcAction;
QAction *aboutAction;
는 함수의 함수 :
void MainWindow::createMenus(){
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(newAction);
fileMenu->addAction(openAction);
fileMenu->addAction(saveAction);
fileMenu->addAction(saveAsAction);
separatorAction = fileMenu->addSeparator();
for (int i = 0; i < MaxRecentFiles; ++i)
fileMenu->addAction(recentFileActions[i]);
fileMenu->addSeparator();
fileMenu->addAction(exitAction);
...
누군가이 오류가 어디에서 발생하는지 알 수 있습니다. ROM?
감사합니다. 당신이 다음 메뉴에 삽입하는 - 악셀
createActions()
에서
내 행동이 헤더에서 초기화되고 관련 부분이 추가됩니다. – Axel
@Axel 방금 추가 한 내용 - 헤더에 포인터가 정의되어 있습니다 ... saveAction = new QAction()'을 어디에서합니까? 그게 그들이 만들어지면 * – tmpearce
오, 그냥 어떤 행동이 구현되지 않았다는 것을 깨달았습니다. 오류로 컴파일하는 동안 이런 종류의 오류가 발생하기 때문에 재미 있습니다. 그래서 나는 QTCreator의 오류 출력 패널에 오류로 표시되지 않았다는 것에 놀랍습니다. oo – Axel