Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Combobox entries in QTableView on a QWizardPage



  • Hi all,
    I have the following page in my wizard, which goes something like this

    Wizard.h
    ----------------------------------------------------------------
    #ifndef WIZARD_H
    #define WIZARD_H
    #include <QWizard>
    ..... //other headers
    QT_BEGIN_NAMESPACE
    class QTableView;
    class QItemDelegate; //not sure if this should be QComboBox, ComboBoxDelegate
    ....... // bunch of other things
    QT_END_NAMESPACE
    // Define the wizard class
    class Wizard : public QWizard
    {
    Q_OBJECT

    public:
    Wizard(QWidget *parent = 0);
    
    void accept() override;
    };
    
    class AWizardPage : public QWizardPage {
    Q_OBJECT
    public:
        AWizardPage(QWidget *parent =0);
    
    private:
        QTableView *sometableview;
        QAbstractItemModel *data_parameters;
        QItemDelegate *comboboxdelegate //again not sure if needs changing
    };
    .....
     #endif
    

    Wizard.cpp
    ----------------------------------------------------------------

     #include "wizard.h"
    Wizard::Wizard(QWidget *parent)
    : QWizard(parent)
    {
        addPage(new AWizardPage);
       .... //format options 
    }
    
    AWizardPage::AWizardPage(QWidget *parent) : QWizardPage(parent)
    {
        sometableview = new QTableView(this);
       data_parameters = new QAbstractItemModel(this);
    
        sometableview->setModel(data_parameters);
    }
    

    The problem to solve is as follows:
    Build a table model where with an add row delete row button, as well as force the cells in the ith column to be a combobox (or similar) for the user to select.

    Any ideas on how I could implement this? Many thanks!


  • Lifetime Qt Champion

    Hi,

    Where would the original data of your model come from or would it be completely empty ? How many rows are you expecting to create ?

    As for the add/delete row, you can use two QPushButton one with a + and one with a - to start simple.


Log in to reply