Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. how convert qcombox drop down listview to grid view
Forum Updated to NodeBB v4.3 + New Features

how convert qcombox drop down listview to grid view

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 3 Posters 389 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    swansorter
    wrote on last edited by
    #1

    hi
    how to convert qcombox list view to grid view

    S 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      QComboBox::setView comes to mind.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • S swansorter

        hi
        how to convert qcombox list view to grid view

        S Offline
        S Offline
        swansorter
        wrote on last edited by swansorter
        #3

        @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);
        }
        
        
        JonBJ 1 Reply Last reply
        0
        • S swansorter

          @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);
          }
          
          
          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @swansorter
          The code shows you are using a QComboBox. Is there any other relevance we are supposed to see?

          What did you do about following @SGaist's advice?

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved