Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3454000
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:26:27+00:00 2026-05-18T09:26:27+00:00

I want a contextmenu on the cells in my QTableView, so first I connected:

  • 0

I want a contextmenu on the cells in my QTableView, so first I connected:

connect(ui->tblTimesheet,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(sheetContextMenu(const QPoint &)));

And the slot for that connect is below:

void wndMyWindow::sheetContextMenu(const QPoint &pos){
    QMenu *menu = new QMenu;
    QModelIndex cell = ui->tblTimesheet->indexAt(pos);
    // Make sure the right click occured on a cell!
    if(cell.isValid()){
        QString myid=cell.sibling(cell.row(),0).data().toString();
        menu->addAction("Remove item", this, SLOT(sheetRemoveItem()));
        menu->exec(ui->tblTimesheet->mapToGlobal(pos));
    }
}

Which creates the menu and puts an action in the menu which calls a function when that action is clicked. However, I want to pass through the variable myid into the second slot. That slot is listed below:

void wndMyWindow::sheetRemoveItem(){
    qDebug("Sure I'm here, but what info do I have?");
    return;
}

I’m not quite sure how to do this, can anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:26:28+00:00Added an answer on May 18, 2026 at 9:26 am

    In this regard, Qt signals/slots suck compared to callbacks and other signal/slot mechanisms. You really can’t attach extra information.

    Couple things you can do though:

    1. Create an object that stores the information you want to send, give it a slot and attach to the signal you want to respond to, emit a new signal with the information, attach to that signal.

    2. Use the Qt signal map thingy to attach some small variation of data to a signal.

    3. You can get the sender in a Qt slot. This may be the information you need. (see the Qt docs on signals/slots).

    If none of those methods work for you, sorry to say but, you’re pretty much fscked. I’m working on a method to auto-create #1 and attach to a boost::signal, which would be more powerful, but it’s going to require a lot of hard work because Qt is incompatible with the C++ preprocessor and with templates.

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know what to do. I want to make this: $('.message').contextMenu('myMenu1', { bindings:
i want to change my ContextMenu based on my layout - and for that
I want to disable the default contextMenu when a user right-clicks on an input
I want to set the CommandTarget of the MenuItem of ContextMenu, in a Style,
I need to create a ContextMenu where I want to pass a currently selected
I'm adding a ContextMenu to a WinForm application and I want to associate it
I have a WPF contextmenu and I want to add an Item with Icon
I'm attempting to use a ContextMenu. I've successfully done this for a simple ListActivity
When I use ContextMenu from Silverlight 4 Toolkit I want to get ContextMenu instance's
I use 'contextmenu' and 'types' plugin in jstree and want to define different contextmenu

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.