Open In App

PyQt5 QDockWidget – Getting Layout Direction

Last Updated : 29 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article we will see how we can get the layout direction of 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). Layout specifies how the children get arranged, by setting layout direction we can specify the order of the arrangement, it can be set with the help of setLayoutDirection method.
 

In order to do this we will use layoutDirection method with the dock widget object.
Syntax : dock.layoutDirection()
Argument : It takes no argument
Return : It returns direction object 
 

Below is the implementation 
 

Python3




# importing libraries
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
 
 
class Window(QMainWindow):
 
    def __init__(self):
        super().__init__()
 
        # setting title
        self.setWindowTitle("Python ")
 
        # setting geometry
        self.setGeometry(100, 100, 500, 400)
 
        # calling method
        self.UiComponents()
 
        # showing all the widgets
        self.show()
 
    # method for components
    def UiComponents(self):
 
        # creating dock widget
        dock = QDockWidget(self)
 
        # setting title to the dock widget
        dock.setWindowTitle("                   GfG ")
 
 
        # push button
        push = QPushButton("Press", self)
 
        # setting widget to the dock
        dock.setWidget(push)
 
        # setting layout direction
        dock.setLayoutDirection(Qt.RightToLeft)
 
        # creating a label
        label = QLabel("GfG", self)
 
        # setting geometry to the label
        label.setGeometry(100, 200, 300, 80)
 
        # making label multi line
        label.setWordWrap(True)
 
        # setting geometry tot he dock widget
        dock.setGeometry(100, 0, 200, 30)
 
        # getting layout direction of dock
        value = dock.layoutDirection()
 
        # setting text to the label
        label.setText("Layout Direction : " + str(value))
 
 
# create pyqt5 app
App = QApplication(sys.argv)
 
# create the instance of our Window
window = Window()
 
# start the app
sys.exit(App.exec())


Output : 
 

 



Previous Article
Next Article

Similar Reads

PyQt5 QDockWidget – Setting Layout Direction
In this article we will see how we can set the layout direction 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). Layout specifies how the children get arra
2 min read
PyQt5 QDockWidget – Unsetting Layout Direction
In this article we will see how we can unset the layout direction of 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). Layout specifies how the children get ar
2 min read
PyQt5 QDockWidget – Getting Layout
In this article we will see how we can get the layout 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). Layout specifies how the internal component will be
2 min read
PyQt5 QDateTimeEdit – Getting Layout Direction
In this article we will see how we can get layout direction of the QDateTimeEdit widget. Layout direction specifies the direction of the QDateTime, by default the arrow buttons which increment or decrement date-time are on the right-hand side although by setting layout direction with the help of setLayoutDirection method, they can appear on the lef
2 min read
PyQt5 QDockWidget – Setting Layout
In this article we will see how we can set the layout to the QDockWidget. QDockWidget provides the concept of dock widgets, also known 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). Layout specifies how the internal component will be
2 min read
PyQt5 QDockWidget – Getting its widget
In this article we will see how we can get widget of the QDockWidget. QDockWidget provides the concept of dock widgets, also known 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 can add widget to the dock widget with the help of s
2 min read
PyQt5 QDockWidget – Getting features from it
In this article we will see how we can get features of the QDockWidget. QDockWidget provides the concept of dock widgets, also known 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). There are many features already enabled for the dock,
2 min read
PyQt5 QDockWidget – Getting Feature change signal
In this article we will see how we can get feature change signal of the QDockWidget. QDockWidget provides the concept of dock widgets, also known 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). There are many features already enabled
2 min read
PyQt5 QDockWidget – Getting Allowed Areas
In this article we will see how we can get allowed areas of the QDockWidget. QDockWidget provides the concept of dock widgets, also known 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). Dock can be moved anywhere in the main window, s
2 min read
PyQt5 QDockWidget – Getting Window Title
In this article we will see how we can get the window title of 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). This property holds the dock widget title (cap
2 min read