PyQt5 QDockWidget – Setting Multiple Widgets Inside it
In this article we will see how we add/set multiple widgets to the QDockWidget. QDockWidget provides the concept of dock widgets, also know as tool palettes or utility windows. Dock windows are secondary windows placed in the dock widget area around the central widget in a QMainWindow(original window). We use setWidget method to add/set widget to the dock widget. But this is used to set only single widget.
In order to set multiple widgets inside it we have to do the following
1. Create a Main Window Class
2. Inside the class create a QDockWidget object and set its properties
3. Create a QWidget object
4. Create a QLayout object
5. Create various widget object which we want to add in the QDockWidget
6. Add these widgets to the layout created earlier with the help of addWidget method
7. Set this laypout to the QWidget object with the help of setLayout method
8. Set this QWidget object to the QDockWidget object with the help of setWidget method
Below is the implementation
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course