c++ - QT QTableView implementing toggle button and checkbox delegates -


i'm trying build qt table subclassing qtableview, qabstracttablemodel , qstyleditemdelegate maintian semblance of mvc archiectecture.

i'm using simple example base build on haven't gone near qt table classes before:

http://qt-project.org/doc/qt-4.8/modelview.html

anyway table text columns needs single toggle button column , single checkbox column.

i've noticed data method of model can used implement checkbox i'm going need custom delegate button going use checkbox also.

anyway i'm unable find decent examples on internet create tables using qtableview object mixture of text, checkboxes , buttons. can of sirs point me in right direction?

you don't need custom delegate having checkbox , toggle button in tableview. can make item checkable , set model like:

qstandarditem *item = new qstandarditem( true ); item->setcheckable(true); item->setcheckstate(qt::unchecked);  qstandarditemmodel * model = new qstandarditemmodel( 0, 2 ); model->setrowcount(1); model->setitem(0, 0, item); 

for toggle button can like:

qpushbutton * = new qpushbutton(this); but->setcheckable(true); but->settext("toggle");  ui->tableview->setindexwidget(model->item(0,1)->index(),but); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -