Search code examples
qt5pyqt5qlabelqpixmapqtabwidget

Are widgets in tabwidget disabled after switching tabs


I'm currently making a big application with PyQt5 with a QTabWidget.

In two tabs are video streams playing. I implemented them with QLabels, that keep refreshing with setPixmap().

When the user changes the tab, is the QLabel in the inactive tab (the tab that the user just left) still enabled and playing the video? It would be optimal when only one video is playing in the tab that is currently opened (for a better performance).

I already read the docs, but couldn't find anything about it.


Solution

  • so, to your question:

    Are widgets in tabwidget disabled after switching tabs?

    no, they only get disabled if you explicit disabled then OR if a parent widget gets disabled...

    to solve your player issue, you can as suggested connect slots in the tabWidget

    this one can be the one you need:

    currentChanged(int index)
    

    when the tab index changes the slot will be called and you get as parameter the index of the new tab (0 based of course.)

    then you can check whether the player's tab is the current or not and according to that pause or resume the movie