Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Mouse ShortCut menu on DialogWindows?
Qt 6.11 is out! See what's new in the release blog

Mouse ShortCut menu on DialogWindows?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MucipM Offline
    MucipM Offline
    Mucip
    wrote on last edited by
    #1

    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:)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • MucipM Offline
        MucipM Offline
        Mucip
        wrote on last edited by
        #3

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

        Regards,
        Mucip:)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved