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. QTabBar customContextMenuRequested
Forum Updated to NodeBB v4.3 + New Features

QTabBar customContextMenuRequested

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 211 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    I've connected my tab bar customContextMenuRequested signal to a slot in my code using a slot that should be picked up by connectSlotsByName()

    ui_StackingDlg.h file

    QTabBar *tabBar;
    

    StackingDlg header:

    public slots:
    	void on_tabBar_customContextMenuRequested(const QPoint& pos);
    

    code:

    void StackingDlg::on_tabBar_customContextMenuRequested(const QPoint& pos)
    {
    	ZFUNCTRACE_RUNTIME();
    	qDebug() << "__FUNCTION__";
    }
    

    I get no complaints about not being able to match the slot.

    However when I RMB on any of the tabs, the slot isn't driven.

    JonBJ 1 Reply Last reply
    0
    • PerdrixP Perdrix

      I've connected my tab bar customContextMenuRequested signal to a slot in my code using a slot that should be picked up by connectSlotsByName()

      ui_StackingDlg.h file

      QTabBar *tabBar;
      

      StackingDlg header:

      public slots:
      	void on_tabBar_customContextMenuRequested(const QPoint& pos);
      

      code:

      void StackingDlg::on_tabBar_customContextMenuRequested(const QPoint& pos)
      {
      	ZFUNCTRACE_RUNTIME();
      	qDebug() << "__FUNCTION__";
      }
      

      I get no complaints about not being able to match the slot.

      However when I RMB on any of the tabs, the slot isn't driven.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Perdrix
      Guess: https://doc.qt.io/qt-6/qwidget.html#contextMenuPolicy-prop, setContextMenuPolicy(Qt::CustomContextMenu) ?
      Otherwise don't use connectSlotsByName(), use explicit connect()s so you know for sure what is going on. Or look in your ui_....h in the build directory to see the code generated from the .ui file

      1 Reply Last reply
      1
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by
        #3

        ui->tabBar->setContextMenuPolicy(Qt::CustomContextMenu);

        fixed it

        Thank you sir.

        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