K
K
Kirill H2017-01-08 18:33:45
Qt
Kirill H, 2017-01-08 18:33:45

How to access a QT form element?

A Horizontal Slide was created on the form, and also an LCD Number.
Necessary:
​​Link them so that after changing the slider, the numbers in the number change.
To solve this problem, I create a slot void on_Slider1_sliderPressed(); In it, I want to turn to Conuter1 (this is my LCD), but it doesn’t work out in any way, when typing his name and accessing through the dot or arrow of the reaction 0, moreover, he simply does not see him. How to work with it? Why doesn't QT see the elements created on the form?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
LancerX0, 2017-01-13
@KirillHelm

How to work with it? Why doesn't QT see the elements created on the form?

When using *.ui forms, all references to elements in the code occur in the form:
In this case, label is an element on the form.
Necessary:
​​Link them so that after changing the slider, the numbers in the number change.

Accordingly, in your case it follows in the function void on_Slider1_sliderPressed(); paste ui->Conuter1->display(ui->Slider1->value());
Now a little more:
ui->Slider1->value()Returns the value in the slider
ui->Conuter1->display(int number);Displays the number on your LCD Number
P.S. Also, this process can be performed by connecting the signal from the slider and the LCD Number slot

R
RabraBabr, 2017-01-09
@RabraBabr

A Horizontal Slide was created on the form, and also an LCD Number.
Necessary:
​​Link them so that after changing the slider, the numbers in the number change.
Hmm... Try and use QML?
If from C++. Try to dig towards Q_PROPERTY and Q_INVOKABLE.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question