Mouse ShortCut menu on DialogWindows?
Solved
General and Desktop
-
Hi,
Normally I use ShortCut Menu on Mainwindow like below code
In constructor:ui->tVDetay->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->tVDetay, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenuTalep(const QPoint&)));
And the pordedure is:
void StokBilgiGiris::ShowContextMenuTalep(const QPoint& pos) { QPoint globalPos = ui->tVDetay->mapToGlobal(pos); QMenu myMenuX; myMenuX.addAction("Stok Bilgisi Göster"); QAction* selectedItem = myMenuX.exec(globalPos); // Hiçbir şey tıklanmazsa hata vermesin diye... :) if (selectedItem == nullptr) return; QModelIndex index; index = ui->tVDetay->currentIndex(); if(!index.isValid()) { QMessageBox::warning(this,"Seçim Hatası", "Seçili bir satır olması gerekir!"); return; } if (selectedItem->text() == "Stok Bilgisi Göster" ) { } }
But I don' know why Below line has error
QMenu myMenuX;
And teh error message is:
D:\Belgeler\Qt\CSI_Yonetim\stokbilgigiris.cpp:65: error: variable has incomplete type 'QMenu'
D:\ProgramFiles\Qt\5.10.1\msvc2017_64\include\QtWidgets\qlineedit.h:54: forward declaration of 'QMenu'What is the problem?
Regards,
Mucip:) -
Hi,
You are missing
#include <QMenu>
.The incomplete type error means that you are missing the definition of the class which usually means that you didn't include the corresponding header.
-
You won't have any linker error since the code cannot be compiled because of the missing include.