PDA

View Full Version : QTableWidget cell clicked



Archa4
6th April 2011, 12:22
I need to activate a slot when the 0, 0 cell of My table is clicked.
I tried to use

connect(table, SIGNAL(cellClicked(int,int)), this, SLOT(previousWeek()));
But it doesn't specify what cell needs to be clicked, so the slot is activated when any cell is clicked.
I also tried to specify the cellClicked(int,int) as cellClicked(0,0), but then i get a warning:
No such signal QTableWidget::cellClicked(0,0)

How do i solve this problem?

JohannesMunk
6th April 2011, 12:26
connect(table, SIGNAL(cellClicked(int,int)), this, SLOT(previousWeek(int,int)));

void YourClass::previousWeek(int row,int col)
{
...
}

Joh

Archa4
6th April 2011, 12:48
Thanks!
I just solved this myself in same way :)

Another question - how to make items not editable (i mean disable the edit on double click)?

JohannesMunk
6th April 2011, 13:01
Just have a look at a sibling post of yours I have been answering today:

http://www.qtcentre.org/threads/40369-Odd-behavior-when-populating-a-Table

HIH

Johannes

Archa4
6th April 2011, 13:05
Thanks again!
Just read that one, but i choose:

item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);

Could i get in trouble using that?

JohannesMunk
6th April 2011, 13:08
No, I don't think that will get you in any trouble. It just seems rather 'unstraightforward' to positively specify flags, where what your code really wants to achieve is disable a specific one. In terms of code readability..

Joh