Hello, friends!
I want to create a special version of QTableWidget that does special things when it is clicked on some if its cells.
I will reuse it several times.
I've created a new class SelVarTable
class SelVarTable
{
Q_OBJECT
private:
// some other stuff
public slots:
void cellClicked_(int r, int c);
// some other stuff
};
class SelVarTable
{
Q_OBJECT
private:
QTableWidget *myTable;
// some other stuff
public slots:
void cellClicked_(int r, int c);
// some other stuff
};
To copy to clipboard, switch view to plain text mode
and I wrote the following initialization code:
SelVarTable
::SelVarTable(QWidget *parent
){
// some other stuff
QObject::connect(myTable,
SIGNAL(cellClicked
(int,
int)),
this,
SLOT(cellClicked_
(int,
int)));
}
SelVarTable::SelVarTable(QWidget *parent)
{
myTable=new QTableWidget(parent);
// some other stuff
QObject::connect(myTable, SIGNAL(cellClicked(int,int)), this, SLOT(cellClicked_(int,int)));
}
To copy to clipboard, switch view to plain text mode
But when I compile I get for the QObject::connect (row 5 of the above code) command the following error
error: no matching function for call to 'QObject::connect(QTableWidget*&, const char*, SelVarTable* const, const char*)'
candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
note: static bool QObject::connect(const QObject*, const QMetaMethod&, const QObject*, const
note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
I could not understand what is wrong.
I cannot believe that it is not possible to connect a signal in a QWidget to a slot in a class that has that QWidget as one of its elements.
I've also tried a totally different way (inheriting SelVarTable from QTableWidget) but had other issues. I first will try to understand why this code does not work.
Someone can help?
Thank you.
Bookmarks