[SOLVED] QTableWidgetItem no data only check flag
-
wrote on 5 Jul 2011, 10:45 last edited by
I've got some QTableWidget, and initializing items like this:
@QTableWidgetItem * item = table->item(i,j);if(item == NULL)
{
item = new QTableWidgetItem();
item->setFlags(Qt::NoItemFlags);
m_ui->tableWidget->setItem(i,j,item);
}if(m_ec.matrix[headerId_i][headerId_j]) // value
item->setData(Qt::CheckStateRole, Qt::Checked);
else
item->setData(Qt::CheckStateRole, Qt::Unchecked);if(m_rn.matrix[headerId_i][headerId_j]))// readonly
item->setFlags(Qt::NoItemFlags);
else
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsUserCheckable);@
I mean I need checkable items in table with maybe some UserRole data and toolTips but w/o Display data. I get this but I still have some space in cells of my table. The question is how to remove or maybe hide these empties ? -
wrote on 7 Jul 2011, 05:31 last edited by
Or maybe anyone know how to set chekbox in center of cell ?
-
wrote on 7 Jul 2011, 05:36 last edited by
You can only put the checkbox in the center of a cell, if you create your own delegate. That is not worth it, I think.
Couldn't you just make the column with your checkboxes narrow enough so it basically only shows your check box?
-
wrote on 7 Jul 2011, 06:16 last edited by
Thanks. I think it's really don't worth it to make a delegate. I asked because I don't know simple method but maybe someone knows. I resize my column close enough but some header text is bigger then 3 symbols long, so there is no way to do SIMPLE nice look, without using delegate.
-
wrote on 7 Jul 2011, 06:24 last edited by
You could considder, if you have space to fill, to just put a textual representation of the value next to the check box. Depending on the meaning, that could be yes/no, true/false, on/off, or something short and simple like that.
-
wrote on 7 Jul 2011, 07:36 last edited by
I found solution I made my horizontal headers only digits in data role, and all text in tool tip role, but vertical header leave with text(because it's actually duplicates horizontal header) . So now it has a nice look. Andre, thanks for the help.
1/6