@Tom-asso said in Newbie question: How to spin a BusyIndicator while loading file data?:
Just starting out with Qt threading api and have some questions. My C++/QML app reads data from a large file and displays it; the QML-defined GUI lets the user modify the display (e.g. with color maps, view angles, etc), and also provides a menu item to load data from another file. While loading data, I would like a QML BusyIndicator to spin, until the data is ready to display. While the BusyIndicator is spinning, the user should be prevented from trying to modify the display through the GUI. I realize the GUI thread must be running in order to spin the BusyIndicator, so presumably my GUI thread code should at least set the BusyIndicator.running property, and launch a worker thread which actually opens the new file and loads its data.
What’s the best way to run a worker thread with Qt’s api?
Do you plan to allow cancellation of loading?
How do I prevent user interaction with other GUI controls while the worker thread is doing its job?
Item has an enabled property that controls mouse and keyboard input for the item and its children. Eg:
import QtQuick 2.12
import QtQuick.Window 2.12
Window {
contentItem.enabled: false
TextInput {
anchors.centerIn: parent
text: "This input is disabled by its parent"
}
}
@AxelVienna said in Newbie question: How to spin a BusyIndicator while loading file data?
QApplication::setOverrideCursor(Qt::WaitCursor);
QGuiApplication, not QApplication. There's no need to involve widgets for a QML/Quick application.