0
0
0nk0l0g2016-02-12 14:50:57
Qt
0nk0l0g, 2016-02-12 14:50:57

How to change the property of an element on a form from another class?

Hello, I recently started to learn qt and had this problem.
There is a class MyGLWidget, in one of its methods there are calculations, the result of these calculations (an integer) must be thrown into the standard slider. There is no way to do it.
I'm trying like this:
in the MyGLWidget class I add the public field Ui::Window *ui
to the class constructor I add ui->setupUi(this);
and already in one of the class methods I try to refer to the form element: ui->log_position__Slider->setValue(value);
Prompt how correctly to organize change of property of an element on the form.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Antony, 2016-02-12
@0nk0l0g

As far as I remember, setValue is a slot, you can attach a signal to it from something that generates a value.
If this is not a slot, then make a slot for the ParentWidget of the progressbar and set the value in it.
Although if all the widgets are on the same UI, then you can directly pull it. Just do not forget to do all the "long" and "potentially long" calculations in a separate thread (from drawing the interface).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question