QT Creatorでスプレッドシートアプリケーションを実行しようとしていて、エラーなしでコンパイルしますが、アプリケーションを実行しようとすると次のエラーが発生します。QWidget::insertAction Attempt to insert null action
問題はQT Creatorのエラーセクションに表示されず、プログラムを実行しているときに作成された小さな端末にエラーが表示されないということです。QWidget :: insertAction実行時にnullアクションを挿入しようとしました
私はcreateActions()
の機能を持っています。ヘッダーに初期化されているすべてのアクションが初期化されています。
ヘッダのプライベート部分でのアクションは、次のようになります。
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::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()
のメニューに追加されます関数:
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