For some particular QTableWidgetItem items, I need to suppress the cellClicked(int, int) signal or I need to disable that item. Is there any way that I can easily do it.
Thank you.
For some particular QTableWidgetItem items, I need to suppress the cellClicked(int, int) signal or I need to disable that item. Is there any way that I can easily do it.
Thank you.
Do you want to disable the clickable option of the item, then set the appropriate flag for the item.
If you want to just supress the cellClicked() then it is not possible, you will have to handle that in the connected slot, by identifying the item by row and col.
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
Yeah, disable clickable option will do.
I tried,But in my slot, I'm still find the cellClicked() signal for that cell getting emitted.Qt Code:
To copy to clipboard, switch view to plain text mode
BTW, I'm having a Icon for those cells which I'm going to click, I'm setting the icon using setItem(nRow, nCol, new QTableWidgetItem(QIcon(":/imgs/updateIcon.png"), ""); Will that cause any problem?
I need to disable clickable option some particular cells. Thank you.
First be clear of what you want.BTW, I'm having a Icon for those cells which I'm going to click, I'm setting the icon using setItem(nRow, nCol, new QTableWidgetItem(QIcon(":/imgs/updateIcon.png"), ""); Will that cause any problem?
1. Do you want the item/icon to be clickable and not emit the signal
You cannot stop/supress the signal, you can only filter it out in the slot.
2.Do you want the item not to be clickable
If yes, then use item's API to disable click
Qt Code:
To copy to clipboard, switch view to plain text mode
Hmm, now you want to disableMy aim is to disable some particular cells. Thank you.
Qt Code:
To copy to clipboard, switch view to plain text mode
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
Thank you Wysota & Santosh,
If I click on a particular cell, I don't want cellClicked() signal from that cell. I'm trying to give more info what I've done here by saying that cell has got an icon also.
If disable doesn't emit, cellClicked signal, then it's good for me. I tried to set above said flags, I was still able to see my debug messages in my slot for cellClicked signal.
If you are still not able to disable the item, please show us what you did.
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
Forget cellClicked(), focus on the goal you wish to achieve.
CResultsTbl is a table.
For the else if(s == "false") and else, I don't want to add the data into map (inCReportsPage class)Qt Code:
// cresultstbl.cpp ( Class name: CResultsTbl) void CResultsTbl::loadData() { if(s == "true") { setItem(nRow, Remediate_Col, } else if(s == "false") { setItem(nRow, Remediate_Col, item(nRow, Remediate_Col)->setFlags(item(nRow, Remediate_Col)->flags() & ~Qt::ItemIsEnabled); } else { item(nRow, Remediate_Col)->setFlags(item(nRow, Remediate_Col)->flags() & ~Qt::ItemIsEnabled); } }To copy to clipboard, switch view to plain text mode
In CReportsPage, I'm creating objects, of CResultsTbl and processing
Qt Code:
// vulnTable, patchTable are objects of CResultsTbl void CReportsPage::onCellClicked(int nRow, int nCol) { if(nCol == CResultsTable::Remediate_Col) { switch (tabWidget->currentIndex()) { case 0: // The below debug message getting printed even for the false case in the above code (cresultstbl.cpp) qDebug() << vulnTable->item(nRow, CResultsTable::Id_Col)->text(); remIndiv_Map[vulnTable->item(nRow, CResultsTable::Id_Col)->text()] = vulnTable->item(nRow, CResultsTable::Reference_Col)->text(); break; case 1: qDebug() << "Patch Table"; remIndiv_Map[patchTable->item(nRow, CResultsTable::Id_Col)->text()] = patchTable->item(nRow, CResultsTable::Reference_Col)->text(); break; case 2: qDebug() << "Compliance Table"; remIndiv_Map[complTable->item(nRow, CResultsTable::Id_Col)->text()] = complTable->item(nRow, CResultsTable::Reference_Col)->text(); break; default: break; } if(!indivRem_BatchTimer->isActive()) { indivRem_BatchTimer->start(5000); } } }To copy to clipboard, switch view to plain text mode
Last edited by rawfool; 21st June 2013 at 07:16.
You don't want to add the data into what map?
Kindly check my comment in the code. Thank you for helping.
Qt Code:
switch (tabWidget->currentIndex()) { case 0: // The below debug message getting printed even for the false case in the above code (cresultstbl.cpp) qDebug() << vulnTable->item(nRow, CResultsTable::Id_Col)->text(); // vv // Here I'm copying the clicked cell's row data into a QMap (remIndiv_Map) remIndiv_Map[vulnTable->item(nRow, CResultsTable::Id_Col)->text()] = vulnTable->item(nRow, CResultsTable::Reference_Col)->text(); // ^^ break; ..... .... }To copy to clipboard, switch view to plain text mode
And I don't have the data of which ones are not to be copied, in CReportsPage
Qt Code:
void CResultsTbl::loadData() { if(s == "true") { .... } // here itself I need to filter data which I'm going to add to QMap (CReportsPage::remIndiv_Map) on click of the cell else if(s == "false") { setItem(nRow, Remediate_Col, item(nRow, Remediate_Col)->setFlags(item(nRow, Remediate_Col)->flags() & ~Qt::ItemIsEnabled); } }To copy to clipboard, switch view to plain text mode
Last edited by rawfool; 21st June 2013 at 08:56.
Why are you switch(ing) switch (tabWidget->currentIndex()), you shoud switch for row.
tabWidget->currentIndex() will return QModelIndex not row number. Row number is a parameter of the slot.
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
I'm using switch to find the active table in my QTabWidget on which user is clicked the cell. I have 3 tables in my QTabWidget.
And in a table, I have column called "Fix Issue", where all the cells will have either "Yes" or "Done". So If user clicks on a cell which has "Yes" or "Done", the values are put into QMap for further processing.
So, here I don't need values of the row of cell which has got "Done", even if users clicks tht cell, I should not add that cell's row data into QMap
Then show us where and how are you are disabling the item?
I don't think loadData() is called when user clicks on "Yes" item.
You will have to disable the item in cellClicked() connected slot.
[EDIT] Looks like cellClicked() is emitted even if item is disabled.
You can check if the item is enabled before adding it the map.
Last edited by Santosh Reddy; 21st June 2013 at 12:09. Reason: updated contents
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
rawfool (21st June 2013)
Bookmarks