Multiple Screens in PyQt5: Switch screens without opening a new window

preview_player
Показать описание
Learn how to switch between multiple screens inside one window in PyQt5. Create a PyQt5 GUI with Python with a button that allows you to go to another screen or window.

In this video, you will:
- Use PyQt5 and QtDesigner
- Create an application that has multiple screens
- Go from one screen to another inside the application

For more info:

*************
**Tags**
PyQt5 tutorial
PyQt5 form
PyQt5 Designer
Qt Designer
Qt GUI tutorial
GUI tutorial Python
Graphical User Interface Python
Python tutorial
Рекомендации по теме
Комментарии
Автор

Very good tutorial! However for actually moving between the windows that need to be updated, it would be better to use the insertWidget and removeWidget methods. If you keep adding widgets and incrementing the stack, the old widgets are not deleted and the stack will simply continue to grow and use much more memory than it needs to

theanonymouse
Автор

FINALLY FOUND A GENUINE TUTORIAL. THANK YOU!

someoneontheinternetuvenev
Автор

Why you don't have subtracted 1 when moving from screen 2 to 1 in index?

muhammadali-cvuq
Автор

Thank you so much your help, this is the only video I find helpful in this situation ❤❤

nqobiledlamini
Автор

Thank you very much, this video deserves so many likes

Atharva_Vashist
Автор

Thank you so much, I found this tutorial for a long time and finally, I found it

hungleinh
Автор

This video is helpfull, although I have a question about switching screens. For instance, in this video both of classes are on the same module, right? But in a biggest application, how can I do the switch screen? I have found no way to make swicht screen, which is saved in different modules.

pedrowegner
Автор

Thank You, Your explanation is so descriptive, keep going.

hussainabbas
Автор

Thanks for the wonderful explanation. Exactly what I needed.

PavanTripathi-rjbd
Автор

Hi, thank you very much for this guide. Helped me a lot with PySide6.

Here is a working example of my code which removes the current active Widget to free up memory and then adds a new widget.
KEEP IN MIND:
By doing this you will lose the data of the widget which is being removed. Example of if your first widget is a login screen then you do not want to do this because it will remove their login ID data that the user might have entered, he/she will have to enter everything again. In that instance switching the index will do the trick.



def screen2(self):
s2 = screen2()

widget.addWidget(s2)

going back to screen 1:

def screen1(self):
s1 = screen1()

widget.addWidget(s1)

app = QApplication(sys.argv)
widget = QStackedWidget()


s1 = screen1()
widget.addWidget(s1)
widget.setFixedSize(1124, 844)

widget.show()
app.exec()

abilovestotrade
Автор

Thank you for knowing your content, and I have already subscribed to it.
I became another fan who promotes you to my friend in Korea. 💯 감사합니다

xlobo
Автор

I love you so much like you don't even know. THANK YOU THANK YOU

aNImALzZ
Автор

Thank you... i was looking for something like this!!!!

wickedblue
Автор

Thank you very much! I had a problem that I couldn't switch windows with Controller, after some changes it stopped working. Even though I'm Russian, I understood everything perfectly.

timurka
Автор

Your tutorial is very good, can you do another tutorial to open 2nd window in mdi area, mdi area when clicking file menu action

-mathsinsinhala
Автор

Hey I have a question, doesn't the 2nd method of creating new instances cause memory leaks?

someoneontheinternetuvenev
Автор

When ya adding widgets all time whenever ya switch windows the program use more memory
Shouldn't ya remove widget to get back
Am i wrong?

anonymousghost
Автор

You are fantastic!!!! I loved how well you explained everything and the fact that you focus on functionality.

robpersonalteacher
Автор

Now I can use this concept to implement tabs feature in my project.(making a web browser btw)

ayushmaanyadav
Автор

Hi I have a question, how do I handle the closeEvent of the QStackedWidget?

tommysellbee