Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to add context menu to the table widget header?
Qt 6.12 LTS is out! See what's new in the release blog

How to add context menu to the table widget header?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.7k Views 1 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi i added context menu to a table widget...
    But it is not displaying for table header...what changes i need to do?

    my context menu function is:
    @ void MainWindow::ProvideContextMenu(const QPoint &point)
    {
    QTableWidgetItem *item=filesTable->itemAt(point);

    QPoint globalpos=filesTable->mapToGlobal(point);
    QString cell=item->text();
    cout<<"EVENT GENERATED..."<<cell.toStdString()<<endl;
     
    QAction *pAddAction= new QAction("add",filesTable);
    QAction *pSplitAction= new QAction("SPLIT",filesTable);
    QMenu *pContextMenu = new QMenu( this);
    pContextMenu->addAction(pAddAction);
    pContextMenu->addAction(pSplitAction);
    pContextMenu->exec&#40;globalpos&#41;;
     
    }@
    
    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      The headers are a separate widgets. See [[doc:QHeaderView]].

      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
      • Unsolved