Results 1 to 1 of 1

Thread: how can I populate different widget in QTableView according to the first QComboBox

  1. #1

    Default how can I populate different widget in QTableView according to the first QComboBox

    I have a QTableView(QStandardItemModel) with 2 columns,the first column is ComboDelegate,and i put all database fields into it,now i want put different widget into the second column according to the field shows in the first column,e.g.,the first column's field is course,so the combobox widget would be put into the second column,and the second combobox 's content is history,math,English and so on,another e.g.,the first column's field is borndate,so the date widget will be put into the second column.
    What can I do?

    QWidget *ComboDelegate::createEditor(QWidget *parent,
    const QStyleOptionViewItem &/*option*/,
    const QModelIndex &/*index*/) const
    {
    QComboBox *editor = new QComboBox(parent);
    rexdataForm rex(const_cast<QWidget*>(parent));

    int length=rex.rexdataModel->columnCount();
    for(int i=0;i<length;++i)
    {
    editor->addItem(rex.rexdataModel->headerData(i,Qt::Horizontal).toString());
    }
    editor->installEventFilter(const_cast<ComboDelegate*>(thi s));
    qDebug()<<editor->currentText();//here only output the first field.what the heck?

    editor->installEventFilter(const_cast<ComboDelegate*>(thi s));



    return editor;
    }
    Last edited by maloudatimes; 28th January 2013 at 09:34.

Similar Threads

  1. Replies: 3
    Last Post: 1st February 2011, 11:57
  2. QComboBox in QTableView
    By giker in forum Qt Programming
    Replies: 1
    Last Post: 23rd December 2010, 10:39
  3. How to populate Combobox in QTableView
    By ronak.vashi in forum Newbie
    Replies: 8
    Last Post: 4th December 2010, 17:09
  4. QCombobox as QTableView delegate
    By martonmiklos in forum Qt Programming
    Replies: 7
    Last Post: 13th June 2010, 15:23
  5. Using QSettings to populate a QComboBox
    By nbkhwjm in forum Newbie
    Replies: 16
    Last Post: 4th September 2007, 22:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.