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. QSqlRelationalTableModel with two ComboBox independent
Forum Updated to NodeBB v4.3 + New Features

QSqlRelationalTableModel with two ComboBox independent

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k 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.
  • P Offline
    P Offline
    parcpaes
    wrote on last edited by
    #1

    hi all
    I have table(area charge) with is one table between area and charge, one area have many charges and one have charge belongs to one area,my objective is filter the QComboBox charge the select the QCombox area what show all charge the area.
    Code here
    @
    modelAreacharge = new QSqlRelationalTableModel(this);
    modelAreacharge->setTable("area_charge");
    modelAreacharge->setRelation(modelAreacharge->fieldIndex("id_area"),QSqlRelation("area_trabajo","id_area","name"));
    modelAreacharge->setRelation(modelAreacharge->fieldIndex("idcharge"),QSqlRelation("charge","idcharge","name"));

    ui->comboBox_area->setModel(modelAreacharge->relationModel(modelAreacharge->fieldIndex("id_area")));
    ui->comboBox_area->setModelColumn(1);
    modelAreacharge->setFilter("id_area = 2");//filter area for chages
    ui->comboBox_charge->setModel(modelAreacharge->relationModel(modelAreacharge->fieldIndex("idcharge")));
    ui->comboBox_charge->setModelColumn(1);
    

    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      And the question is...?

      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