Unsolved QTabWidget, Signal & Slot
-
Perhaps use a timer to delay the updating:
void MaFenetre::isChanged(int pos){ if(pos == 0) { QTimer::singleShot(200, this, &MaFenetre::updateMain); } }
-
There's some kind of strange loop here.
Basically, when allTab has its index changed to 0, you set it to 0 again, and then call updateMain. What is the purpose of allTab in MaFenêtre ?
-
@TheBadger said:
Perhaps use a timer to delay the updating:
void MaFenetre::isChanged(int pos){ if(pos == 0) { QTimer::singleShot(200, this, &MaFenetre::updateMain); } }
Thanks a lot, This solution worked fine for me !
@SGaist said:
There's some kind of strange loop here.
Basically, when allTab has its index changed to 0, you set it to 0 again, and then call updateMain. What is the purpose of allTab in MaFenêtre ?
The fact is that it wasn't changing my tab until
updateMain();
finished. As my function take some time to be executed (2-3 seconds) when I was clicking on the index 0, i had a delay of 2-3 seconds before it switched to this tab. -
Should that updating happen only before that tab is shown ?
-
@SGaist said:
Should that updating happen only before that tab is shown ?
Kind of. It's useless to update it while the user don't want to see them.
-
In that case why not trigger it through the showEvent of your widget ?
What makes that update take so much time ?
-
I apologize for the delay.
I'm downloading a picture during the update, that's why it is taking so much time.
Of course, I could do a QThread, but I try to use them as less as possible to not over thread. -
Are you downloading it each time ?
-
Yes, I want to download it again each time I'm back on my update tab.
-
In that case why not add a spinner or busy indicator and show the widget directly ? It will at least remove the feeling that your application is stuck.