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

  • SEARCH
  • Home
  • 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 4347744
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:20:54+00:00 2026-05-21T12:20:54+00:00

I have a QTableWidget in my program that I use to display results and

  • 0

I have a QTableWidget in my program that I use to display results and I am trying to be able to detect when a user single clicks one of the vertical headers. To do this I am trying to connect the signal sectionDoubleClicked(int) to my function hheaderclicked(int). When I try to compile the code I get a compile time error about no matching function. I am basing my code from the post here

Compile Error:

mainwindow.cpp:138: error: no matching function for call to âMainWindow::connect(QHeaderView*, const char [27], MainWindow* const, const char [21])â
/usr/lib64/qt4/include/QtCore/qobject.h:181: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
/usr/lib64/qt4/include/QtCore/qobject.h:282: note:                 bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const

My Code:

QObject::connect(ui->table_results->horizontalHeader(),SIGNAL(sectionDoubleClicked(int)),
              this,SLOT(hheaderclicked(int)));

Edit:
I was able to get my code to work by doing the following:

QObject::connect((QObject*)ui->table_results->verticalHeader(),SIGNAL(sectionClicked(int)),this,SLOT(hheaderclicked(int)));

Can some one explain why I had to cast QHeaderView* to QObject* to get this to work, i don’t have to cast any of my other QObject::connect calls and they all work fine. For example this work fine:

QObject::connect(ui->button_start,SIGNAL(clicked()),this,SLOT(scanstart()));

is it because this one is connecting to a known object at compile time while my other one is connecting to a object that won’t be known till runtime?

  • 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-21T12:20:55+00:00Added an answer on May 21, 2026 at 12:20 pm

    The error message gives the third argument as MainWindow* const, which is rather odd. If it was const MainWindow*, the call should work. How is the calling function declared?

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

Sidebar

Related Questions

I have a QTableWidget that has a combination of QLineEdit and normal table cell
In my application, I have QTableWidget displaying multiple rows, a line edit to enter
I have this application where the user can draw some custom QGraphicsItems in a
I use Qt Designer to build my UI layout. On the layout, I have
I have a strange problem when trying to add buttons to a QWidget during
Hopefully a very quick question. In one of my functions I want to generate
I have an issue with a table->setItem(index, 0, widg); statement having unwanted side-effects. I
I have a very strange error in my Qt project. Here is the code,
Have a lot of troubles on production server. Some routing cause crashing of Application
Very quick question here. I was wondering if it is possible for me to

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.