If anyone is after a similar topic try searching for setView.
I got the following to work with ideas from this forum and a colleague.
I got to make a class for it now.
for (int i = 0; i < model->rowCount(); ++i) {
model->setItem(i, 0, col0);
model->setItem(i, 1, col1);
}
tableView->setModel( model );
tableView->verticalHeader()->setVisible(false);
tableView->horizontalHeader()->setVisible(false);
tableView->setColumnWidth ( 0, 60 );
tableView->setColumnWidth ( 1, 160 );
tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
tableView->setAutoScroll(false);
myComboBox->setModel( model );
myComboBox->setView( tableView );
QStandardItemModel *model = new QStandardItemModel( 3, 2, this );
for (int i = 0; i < model->rowCount(); ++i) {
QStandardItem* col0 = new QStandardItem( QString("foo%0").arg(i) );
QStandardItem* col1 = new QStandardItem( QString("bar%0").arg(i) );
model->setItem(i, 0, col0);
model->setItem(i, 1, col1);
}
QTableView* tableView = new QTableView( this );
tableView->setModel( model );
tableView->verticalHeader()->setVisible(false);
tableView->horizontalHeader()->setVisible(false);
tableView->setColumnWidth ( 0, 60 );
tableView->setColumnWidth ( 1, 160 );
tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->setAutoScroll(false);
myComboBox->setModel( model );
myComboBox->setView( tableView );
To copy to clipboard, switch view to plain text mode
Bookmarks