QWidgetشرح ال

 1. QWidget:-

#introduction:

It is an empty widget that support you to put objects(button,lineEdit..) at any position on the widget using function:move(width, hight).

 

QWidget:however, is not suitable because of following reasons:

· The position of the widget does not change even if the window is resized.

· The appearance may not be uniform on different display devices with different resolutions.

· Modification in the layout is difficult as it may need redesigning the entire form.



 

The advantages of Layout managers over absolute positioning are:

· Widgets inside the window are automatically resized.

· Ensures uniform appearance on display devices with different resolutions

· Adding or removing widget dynamically is possible without having to redesign.

 

#explanation:

moveللعنصر في أمر أنشاءه  ونتحكم في مكان العنصر فيها  بأمر  self  نقوم بتمرير أسمها  QWidget لاضافة العناصر للنافذة

 

                      

Functions:

 

self.close()           #يغلق النافذة

self.showMinimized()يصغر النافذة#   

self.showNormal()يرجع النافذة لحجمها العادي( لو كانت كبيرة)#      

self.showFullScreen()يكبر النافذة للحجم الكامل للشاشة#  

self.setWindowFlag(Qt.FramelessWindowHint)  من النافذة# تزيل شريط العنوان

self.setWindowFlag(Qt.WindowStaysOnTopHint)#تخلي النافذة دائما أعلي التطبيقات الأخري

أكثر من تعديل في نفس الوقت#

self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)

 

 

import sys
from PyQt5.QtWidgets import (QApplication, QWidget, QLineEdit, QPushButton)

class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(240, 130)
        p_1 = QPushButton("Name", self)
        p_1.move(5,10)
        p_2 = QPushButton("Phone", self)
        p_2.move(5,40)
        p_3 = QPushButton("Email", self)
        p_3.move(5,70)
        p_4 = QPushButton("Age", self)
        p_4.move(5,100)


        l_1= QLineEdit(self)
        l_1.move(90,10)
        l_2= QLineEdit(self)
        l_2.move(90,40)
        l_3 = QLineEdit(self)
        l_3.move(90,70)
        l_4 = QLineEdit(self)
        l_4.move(90,100)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example()
    ex.show()
    sys.exit(app.exec_())

قم بتنزيل الصورة في الأسفل وتكبيرها حتي تستطيع قراءة المقال باللغة العربية بشكل أوضح:

 

Comments

Popular posts from this blog

QFormLayoutشرح ال

QGridLayoutشرح ال