S
S
Slavka2015-12-13 17:06:42
Qt
Slavka, 2015-12-13 17:06:42

Qt progressBar, control from own class?

Such a problem, I have a device class, inside it there is a method for sending data via USB, but I would like the sending to be displayed in the progress bar, how can I access the form element from a regular c ++ class?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2015-12-13
@Nipheris

Option 1:
1) make a public method like setTransferProgress(int) in the form class so that it can be called from outside;
2) pull the form method, setting the desired progress value;
3) implement the setTransferProgress method so that it changes the state of the controls as you need;
Option 2:
1) make your "normal" C++ class a QObject class, make it have a transferProgressChanged(int) slot;
2) pass your "data sender" object to the form, and connect slot transferProgressChanged to a private method like updateProgress;
3) update the form controls in updateProgress;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question