[Qt-interest] dataChanged() SIGNAL in proxy models
Mandeep Sandhu
mandeepsandhu.chd at gmail.com
Thu Jul 1 15:47:10 CEST 2010
>> List = 1,2,3,4,5
>>
>> Table:
>> 1,2,3
>> 4,5
>
> You might have seen these, but I'll draw your attention to them anyway:
>
> http://doc.trolltech.com/latest/qlistview.html#LayoutMode-enum
> http://doc.trolltech.com/latest/qlistview.html#batchSize-prop
>
> It doesn't really make the data tabular, but it will lay it out in rows.
I had tried it sometime back. Didn't seem to work then. This is what I
had tried (some quick code):
class Widget : public QWidget
{
public:
Widget(QWidget *parent = 0) : QWidget(parent)
{
QStringListModel *model = new QStringListModel(this);
QStringList list;
list << "0" << "1" << "2" << "3" << "4" << "5";
model->setStringList(list);
QListView *view = new QListView(this);
view->setModel(model);
view->setLayoutMode(QListView::Batched);
view->setBatchSize(3);
QVBoxLayout *vb = new QVBoxLayout(this);
vb->addWidget(view);
}
~Widget() {}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
Another problem is that I cannot control the number rows that should
be displayed. Setting batch size, I presume, will layout the list
items with columns = batchSize and rows = (total num of list
items)/batchSize [+1 if it's not fully divisable by batchSize]
>
>>
>> The reason I'm doing this is because the source of the data is
>> returning a list but the display has to be tabular (I could still
>> extract the list data and populate a table model, but I though this
>> might turn out to be easier).
>
> If the choice really is between a proxy to turn the stuff into a table or
> implement your own model to structure the data in a tabular way in the first
> place, I still recommend the table model, not the proxy.
Ok. Will think about it.
Thanks,
-mandeep
More information about the Qt-interest-old
mailing list