1

I want to retrieve data from internet and show them into a widget.

In particular, I've a widget with a QComboBox containing some service from which I can retrieve a list of exchange markets.

When I select one item, I want to show related markets in a QTextEdit on the same widget.

In my mind I think to do following steps:

  • Send the request signal when item is selected
  • Start retrieving of data from internet with QNetworkManager
  • At the same time showing a modal waiting widget (with a progress bar or similar)
  • When data is retrieved and parsed, emit a signal with data received from both waiting widget (that will be closed) and to original widget which will be updated.
  • If some error occurs (no internet connection, timeout etc) send another signal with the error code, received from the waiting widget that will shown the error message and then closed. No changes in original widget.

It's a good way to update a widget with data received from internet (or another slow source)? Or is there a better way, or a design pattern to follow in such cases?

0

When you say QNetworkManager, are you referring to QNetworkAccessManager?

In my opinion, it's the best solution in Qt and I do think is the right one.

The steps you mentioned sound good also.

2
  • Yes this was a typo. I will try this pattern. Thanks.
    – Jepessen
    Sep 16 '15 at 18:04
  • Let me know about your progress! :)
    – Tarod
    Sep 16 '15 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.