PDA

View Full Version : Access to UI elements



ivanotero76
25th January 2017, 15:48
Hi everyone!

I am attemptting to access to elements of mainwindow.ui (it would be named ui elements? ).

I have two sample of use of this elements.

First work fine but in case of comboBox It doen't work.

Could you help me?




QString def_fileGbxml = ui->lineEditFile->text();

QComboBox cb_tipoEdificio = this->ui->comboBox_1



How can define it to use in my mainwindow.cpp. I want to load it from file of data.

I have data on file like that:




constructionIdRefs:
cons-1
cons-2
cons-3
cons-4
cons-5
cons-6
***************
openingTypes:
FixedWindow
NonSlidingDoor
end1;
end2;



I can write file like I want. Do you recommend another organization of data??

On the other hand. I read about define manual ComboBox and Label but in this way I can't view it in main window.

For example:




QGridLayout *layoutPrincipal = new QGridLayout();
layoutPrincipal->addWidget(new QLabel("Latitud"),0,0);
latitud = new QLineEdit();
layoutPrincipal->addWidget(latitud,0,1);
layoutPrincipal->addWidget(new QLabel("Longitud"),1,0);
longitud = new QLineEdit();
layoutPrincipal->addWidget(longitud,1,1);

getLocation = new QPushButton("Get Position");
layoutPrincipal->addWidget(getLocation,3,0,1,2);

valores_combo << "primero" << "segundo" << "tercero";
combo_buildings = new QComboBox();

combo_buildings->addItems(valores_combo);

this->setWindowTitle("Config of initial values of gbxml");
this->setLayout(layoutPrincipal);



Is there any way to view this elements in mainwindow.ui?

It is possible a mix of both?

high_flyer
6th February 2017, 13:11
First work fine but in case of comboBox It doen't work.
Yo need to use a pointer:

QComboBox *cb_tipoEdificio = this->ui->comboBox_1

The rest of your post is just very hard to understand.