Problems with Open-Source Downloads read and

Mouse ShortCut menu on DialogWindows?

  • Hi,
    Normally I use ShortCut Menu on Mainwindow like below code
    In constructor:

               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();
            QMessageBox::warning(this,"Seçim Hatası", "Seçili bir satır olması gerekir!");
        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?


  • Lifetime Qt Champion


    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.

  • Hi SGaist,
    Thanks. Yes.
    I confused because there isn't any error like missing library or like?


  • Lifetime Qt Champion

    You won't have any linker error since the code cannot be compiled because of the missing include.

Log in to reply