Pergunta

With PyQT and a QTreeView, I need to display a "loading" message or a "spinning wheel" when the user expands an item, because the childs are retrieved by making a http request.

Any ideas on how to implement this?

Thanks

Foi útil?

Solução

If the time taken to retrieve the child items is relatively short (say, a few seconds), then by far the simplest solution is to display a busy/wait cursor.

You can either set the cursor on the treeview:

treeview.setCursor(QtCore.Qt.BusyCursor)
# retrieve and insert child items ...
treeview.unsetCursor()

or set it globally:

QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor))
# retrieve and insert child items ...
QtGui.QApplication.restoreOverrideCursor()

But other solutions will be much more complicated than this.

For instance you could show a QProgressBar in the status bar, or perhaps use a QMovie to display an animated icon somehow.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top