[Interest] Regarding appending checkbox in QListView

André Somers andre at familiesomers.nl
Mon Feb 23 08:11:20 CET 2015


Jha Sonakumar schreef op 23-2-2015 om 07:43:
>
> Hi all,
>
> Is there anyway to append checkbox in each row of the QListView?
>
> Checkbox can be added  using *QStandardItem*, but i want checkbox 
> should be shown after the item .
>
>
> code:
>
> *QStandardItemModel *model = new QStandardItemModel(this);*
> *for (int i = 0; i < rowCount; ++i) {*
> *        QString sNo = QString::number(i+1);*
> *        QString str  = dHandler.m_infoData.at(i).event;*
> **
> *        QStandardItem *item = new QStandardItem(str.prepend(sNo));*
> *        item->setCheckable(true);*
> **
> *        model->appendRow(item);*
> *    }*
> *    ui->listView->setModel(model);*
>
>
>
General UX advice: don't put the checkbox after the label.

If you still want to do that:
You might experiment with setting RTL mode on your widget, but I'm not 
sure if that will do what you need. It would be a bit of hack anyway. 
The real solution is of course to implement a custom delegate for this. 
Or, use a QTableView instead, and put the checkbox in a separate column.

André


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150223/5b85674c/attachment.html>


More information about the Interest mailing list