How to Open a New Dialog when a Row is Clicked..?



  • !http://www.qtcentre.org/attachment.php?attachmentid=10248&d=1396557161(tableview)!

    Hello world!!

    i am in new in Qt not only Qt but i am new programing and i come over here to get an answer for my question that is:

    i am developing a program with a relationalship until now everything is ok -and- -by Qt- is easy to learn and understand becuase there are a lot of tutorials about everything.. so what i want to do now is.. when i click or select a row in my table then click a button another dialog should be opend and it should display only rows that have the same code in the column.. any idea please?



  • here is my code:

    file.h
    @

    namespace Ui {
    class Deliveries;

    }

    class Deliveries : public QDialog
    {
    Q_OBJECT

    public:
    explicit Deliveries(QWidget *parent = 0);
    ~Deliveries();
    private slots:
    void updateDel();

    private:
    Ui::Deliveries *ui;

    QSqlRelationalTableModel *deliveryModel;

    };

    @

    file.cpp
    @

    Deliveries::Deliveries(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Deliveries)
    {
     
    ui->setupUi(this);
     
    //-------------- connection settings-------------
    Login conn;
    if(!conn.connOpen())
    ui->label_deliveries_statut->setText("Failed to open the database");
    else
    ui->label_deliveries_statut->setText("Connected....");
    //-------------- connection settings-------------
     
    deliveryModel = new QSqlRelationalTableModel(this);
    deliveryModel->setTable("deliveries");
    deliveryModel->select();
     
    deliveryModel->setRelation(deliveryModel->fieldIndex("supplierid"), QSqlRelation("suppliers","id","name"));
    deliveryModel->setRelation(deliveryModel->fieldIndex("productid"), QSqlRelation("products","id","name"));
    deliveryModel->setRelation(deliveryModel->fieldIndex("tva"), QSqlRelation("tva","unity","type"));
    deliveryModel->setRelation(deliveryModel->fieldIndex("departmentid"), QSqlRelation("department","id","name"));
    deliveryModel->setRelation(deliveryModel->fieldIndex("deliverycodeid"), QSqlRelation("deliverycode","id","code"));
     
    deliveryModel->setEditStrategy(QSqlRelationalTableModel::OnManualSubmit);
     
     
     
    ui->deliveryView->setModel(deliveryModel);
     
    ui->deliveryView->setItemDelegate(new QSqlRelationalDelegate(this));
    ui->deliveryView->setAlternatingRowColors(true);
    ui->deliveryView->setCornerButtonEnabled(true);
     
    ui->deliveryView->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->deliveryView->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->deliveryView->setSortingEnabled(true);
    ui->deliveryView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui->deliveryView->horizontalHeader()->setStretchLastSection(true);
    ui->deliveryView->resizeColumnsToContents();
    ui->deliveryView->setCurrentIndex(deliveryModel->index(0, 0));
     
    ui->deliveryView->setColumnHidden(0/*Deliveries_Id*/, true);
     
     
    connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editDel()));
     
    }
     
    Deliveries::~Deliveries()
    {
    delete ui;
    }
     
    void Deliveries::editDel()
    {
    
    }
    }
    

    @

    now what should i do next with editbuton and and the second dialog? please help..



  • Hi jaafari, welcome to DevNet.

    Take a look to "QSortFilterProxyModel":http://qt-project.org/doc/qt-5/qsortfilterproxymodel.html


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.