Problem with function that could be only global or static and displaying contents
-
The problem is that I use GUI where I have some buttons and one of them indicate function that is static. I want to show to user what happens in that function while it is working and I want to know when it finishes. I have to show to user when it finishes because only then he could continue work with program.
-
Hi,
If you want to update the UI while a function is executing, you can call "processEvents()":http://doc.qt.io/qt-5/qcoreapplication.html#processEvents. A better way to use that function is to pass in some flags:
@
qApp->processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers );
@"qApp":http://doc.qt.io/qt-5/qapplication.html#qApp is a macro to QApplication or QCoreApplication depending on the type of application.
-
Hi,
What kind of feedback do you want to give to your user ? Something like a QProgressBar ?
-
Inside that function I do few things. There is:
- progress of function executing
- information that data was saved to the file (and I want to show to user name of saved file)
- information that function ends executing
Firstly, when I started to do this program I also wanted to disable button that is responsible for further executing my program until my function is done. But with static function I can't use signals and I don't know how to do this in other way.
-
It could be great idea, I check if it works in my program, thanks.
-
@ ckakman call a slot from a static function ? Do you mean the slot of the QProgressBar ?
-
[quote author="SGaist" date="1421359077"]@ ckakman call a slot from a static function ? Do you mean the slot of the QProgressBar ?[/quote]
If s/he passes a QObject-derived object's pointer a static function and doesn't feel disturbed by such a hack, why not?
-
Threading issues mostly (not that threading was mentioned)
Out of curiosity why is it mandatory that this function be static or global ?
-
I use a library that need pointer to function, so I can't write my function as a method of my class, because then I get
"argument of type void(MyClass::)() is incompatible with parameter of type void()()"
so the only solution was writing this function as global or static.