I want to learn how to upgrade standard widgets in Pyqt5. It seems that the redesign is done using setStyleSheet, but I did not find a complete list of commands. On the Qt website are just examples. First I decided to do it like in the picture: enter image description here

First snag: how to make text inside QlineEdit. So that when pressed it was like this: enter image description here

Further, as you can see, the bezel changes when pressed. It is also not clear how to set it up. I would be grateful for any information)

    1 answer 1

    The setPlaceholderText(str) function is responsible for the background text, and the bezel can be made with qss

     import sys from PyQt5 import QtGui, QtWidgets class Main(QtWidgets.QWidget): def __init__(self): super().__init__() self.setStyleSheet("QWidget{background-color: #fff;}") self.edit = QtWidgets.QLineEdit() self.edit.setFont(QtGui.QFont("Times New Roman", 14)) self.edit.setPlaceholderText("Номер телефона") self.edit.setFixedHeight(40) self.edit.setStyleSheet(""" QLineEdit{ border: 1px solid #CCD6DD; } """) self.button = QtWidgets.QPushButton("Вход") self.button.setFont(QtGui.QFont("Times New Roman", 12)) self.button.setStyleSheet(""" QPushButton{ font-style: oblique; font-weight: bold; border: 1px solid #1DA1F2; border-radius: 15px; color: #1DA1F2; background-color: #fff; } """) self.button.setFixedSize(100, 40) self.layout = QtWidgets.QHBoxLayout() self.layout.addWidget(self.edit) self.layout.addWidget(self.button) self.setLayout(self.layout) if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) main = Main() main.show() sys.exit(app.exec_()) 

    enter image description here

    • And it is possible for more details about qss. - Michael Shcherbakov
    • one
      @MichaelShcherbakov well, simply put, this css only built into qt you can see the documentation on it - Twiss
    • Yeah got it. Thank you - Michael Shcherbakov