checkboxes in a tableview,
hi, I have a problem with a Table View. It has got 2 columns, the first with checkboxes, the second have Strings coming out from a DB query.
I need to save a file containing only the cells in the second coloumn with checked checkboxes(in the 1st one).
I fill the first column with this portion of code:
Code:
for (row=0; row<model->rowCount(); row++){
ch->setObjectName(name);
ch->setChecked(Qt::Checked);
view->setIndexWidget(model->index(row,0),ch);}
after filling the first column in this way I can't access the state of the checkboxes to select the rows that I want to save in the file.
I am unable to get the state of the checkboxes maybe for the wrong way i used to set the object name.
have you got any idea to help me? thanks in advance!
Re: checkboxes in a tableview,
Hmm... definitely not the right way to do it. Take a look at Qt::CheckStateRole and Qt::ItemIsUserCheckable and forget about index widgets.
Re: checkboxes in a tableview,
sorry but can you be more practical? i'm very new to qt programming (1 month) and i have greats difficulties to find useful examples for really beginners like me.
Qt::CheckStateRole and Qt::ItemIsUserCheckable are to set the properties of the checkboxes i suppose, but now they works like i want with my code, there are some reason because i shouldn't use it? is it deprecated ?
if I have to forget about index widgets how can i do what i need? i tried to use QItemDelegate with no success, and also it's too much complicated for my little job. (create a custom viewtable with checkbox on first coloumn and textview on the second coloumn)
have you a simple example where i can look how to make something that can help me capturing only the text i need to take? :crying:
thanks for helping me.
Re: checkboxes in a tableview,