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 Open a New Dialog when a Row is Clicked..?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 921 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.
  • J Offline
    J Offline
    jaafari
    wrote on last edited by
    #1

    !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?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jaafari
      wrote on last edited by
      #2

      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..

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qxoz
        wrote on last edited by
        #3

        Hi jaafari, welcome to DevNet.

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

        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