Model, view, resize to show all data
Hello,
The constructor is like this:
Code:
{
//Model
//text
int row = model->rowCount(parentIndex);
int col = model->columnCount(parentIndex);
for(int i(0); i<row; ++i)
for(int j(0); j<col; ++j)
{
text->append(model->data(index, Qt::DisplayRole).toString());
}
//view
view->setModel(model);
view->setRootIndex(parentIndex);
//splitter
splitter->addWidget(text);
splitter->addWidget(view);
}
How can I make sure that the text, view, and splitter will resize automatically to display all the data?
Many thanks in advance.
Re: Model, view, resize to show all data
Set a layout for that Test widget or subclass the QSplitter instead of QWidget.
Re: Model, view, resize to show all data
Jacek,
Thanks; things are starting to look good:
Code:
{
//Model
//text
int row = model->rowCount(parentIndex);
int col = model->columnCount(parentIndex);
for(int i(0); i<row; ++i)
for(int j(0); j<col; ++j)
{
text->append(model->data(index, Qt::DisplayRole).toString());
}
//view
view->setModel(model);
view->setRootIndex(parentIndex);
//splitter
mainLayout->addWidget(splitter);
splitter->addWidget(text);
splitter->addWidget(view);
QList<int> list;
list << 1000 << 1000;
splitter->setSizes(list);
}
But the "text" and "view" boxes of the splitter are of the same size. I would like their sizes to adjust automatically to the amount of data that needs to be displayed so that scroll bars would not be needed. I tried to play with the setSizes function but without luck.