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. How to add context menu to the table widget header?
Forum Updated to NodeBB v4.3 + New Features

How to add context menu to the table widget header?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.5k 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.
  • A Offline
    A Offline
    aurora
    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 Extensions
      • Unsolved