Qt formulary in QGis



  • Hello,
    I’m new to Qt so sorry if the question is basic!
    I did a formulary with qt designer, and after I change a little bit the code (the .h and the .cpp) because I want a formulary with two ComboBox relationated. I mean depending on the choice in the first ComboBox the choice list in the second one change.
    My formulary work in Qt, when I test it all is OK but when I try to use it in QGIS it doesn’t works: choice in the second ComboBox never appears. My columns in the QGIS table have the same name as the ComboBox.
    Can you help me?
    Thanks and sorry for my (terrible) English!

    Léa


  • Moderators

    Do you have some code? Without code it is really hard to guess what might be going wrong.



  • Ok,
    this is for example my .h
    @
    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    connect(ui->comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeLinkedComboBox(QString)));

    //init linkedComboBox avec la valeur A de comboBox
    changeLinkedComboBox(ui->comboBox->currentText());
    

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::changeLinkedComboBox(QString text)
    {
    ui->linkedComb->clear();
    QStringList listItems;
    if (text == QString("A"))
    listItems << "a1" << "a2";
    else
    listItems << "b1" << "b2";

    ui->linkedComb->addItems(listItems);
    

    }

    @

    I thik QGIS only read the .ui and note the .h and .cpp at the same time right?

    Edit: please use @ tags around code sections; Andre


Log in to reply
 

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