Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to predefine items in vector of qcombobox

how to predefine items in vector of qcombobox

Scheduled Pinned Locked Moved Solved General and Desktop
qt5.6comboboxvector
2 Posts 2 Posters 1.2k Views
  • 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.
  • V Offline
    V Offline
    vasu_gupta
    wrote on last edited by
    #1

    i have created a vector of combobox like this:

    QVector<QComboBox *> dbox1;
    

    now i want that when ever i add a new comboxox in this vector:

    dbox1.push_back(new QComboBox);
    

    i want that that particular combobox shall some items pre-entered

    dbox1[row_cnt]->addItem(QString("defect 1"));
    dbox1[row_cnt]->addItem(QString("defect 2"));
    dbox1[row_cnt]->addItem(QString("defect 3"));
    dbox1[row_cnt]->addItem(QString("defect 4"));
    dbox1[row_cnt]->addItem(QString("defect 5"));
    

    how to do so

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Just create a function and use that instead of new directly

      
      QComboBox * MakeDefaultCB(QObject *Parent) {
      QComboBox * cur= new QComboBox (Parent);
      cur->addItem(QString("defect 1"));
      cur->addItem(QString("defect 2"));
      ...
      return cur;
      }
      
      dbox1.push_back(MakeDefaultCB(this));
      
      1 Reply Last reply
      4

      • Login

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