Unsolved how convert qcombox drop down listview to grid view
-
hi
how to convert qcombox list view to grid view -
Hi,
QComboBox::setView comes to mind.
-
@swansorter
this is my code which shows color in listview i want it in grid view is it possible#include "mainwindow.h" #include "ui_mainwindow.h" #include <iostream> #include<QDebug> using namespace cv; using namespace std; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QStringList colorNames = QColor::colorNames(); QPixmap px(100,60); ui->comboBox_4->setIconSize(QSize(100, 60)); ui->comboBox_4->setStyleSheet("QComboBox { background-color: white }" "QListView { color: blue; }"); for (int i = 0; i < colorNames.size(); ++i) { px.fill(QColor(colorNames[i])); QIcon icon(px); icon.addPixmap(px); ui->comboBox_4->addItem(icon,"COLOR"+QString::number(i)); } } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_comboBox_4_currentIndexChanged(int index) { QStringList colorNames1= QColor::colorNames(); QColor color(colorNames1[index]); qInfo()<<colorNames1[index]; qInfo()<<color.red(); qInfo()<<color.green(); qInfo()<<color.blue(); QColor colorq(color.red(),color.green(),color.blue()); QString s( "QComboBox { background-color:"+colorNames1[index]+"; }"); ui->comboBox_4->setStyleSheet(s); }
-
@swansorter
The code shows you are using aQComboBox
. Is there any other relevance we are supposed to see?What did you do about following @SGaist's advice?