Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Help to set size of widget



  • I'm trying to set a size to the widget (PasswordEdit) with setGeometry, but not works. I'm want to the PasswordEdit stay on the center... Someone can help about this?

    from PySide2.QtCore import (QCoreApplication, QDate, QDateTime, QMetaObject,
        QObject, QPoint, QRect, QSize, QTime, QUrl, Qt)
    from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont,
        QFontDatabase, QIcon, QKeySequence, QLinearGradient, QPalette, QPainter,
        QPixmap, QRadialGradient)
    from PySide2.QtWidgets import *
    import sys
    from qtwidgets import PasswordEdit
    
    
    class Test(QMainWindow):
        def __init__(self, parent=None): 
            super().__init__(parent) 
            self.setMinimumSize(500, 500)
            password = PasswordEdit()
            password.setGeometry(QRect(100,100,1,100))
            self.setCentralWidget(password)
    
    
    if __name__ == '__main__':
        qt = QApplication(sys.argv)
        app = Test() 
        app.show() 
        qt.exec_() 
    

  • Lifetime Qt Champion

    Hi
    You can use move(x,y) (and resize) instead of setGeometry
    I assume that the password is not affect by any layouts as then moving it is futile :)


Log in to reply