Is it possible to change the number of columns in a QTableView when user dynamically resize the QTableView? For example I have 9 images of number 1-9, I have a QTableView with custom delegate that paint the image into the cell of the table, I would like the QTableView to behave like the way in following picture:
What should be my direction and how should I implement it?
Here is my code for the solution:
QListViewIconModeLtoRFlow::QListViewIconModeLtoRFlow(QWidget *parent): QMainWindow(parent)
{
ui.setupUi(this);
QFrame *frame = new QFrame;
QVBoxLayout *main = new QVBoxLayout(frame);
QListView *list = new QListView;
list->setFlow(QListView::LeftToRight);
list->setResizeMode(QListView::Adjust);
list->setViewMode(QListView::IconMode);
list->setIconSize(QSize(50,50));
QStandardItemModel *model = new QStandardItemModel;
list->setModel(model);
for (int i = 0; i < 50; ++i)
{
QPixmap p("F:\\boro.jpg");
QIcon *icon = new QIcon(p);
QStandardItem *item = new QStandardItem(*icon, NULL); //NULL to hide string appearance
model->appendRow(item);
}
main->addWidget(list);
setCentralWidget(frame);
}
A text will appear below the icon if QStandardItem is constructed as usual:
Pass NULL as the QString parameter instead:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.