简体   繁体   English

使用 PyQt5 禁用 QLineEdit 的大小调整

[英]Disable resizing for QLineEdit with PyQt5

I have multiple user input fields on my GUI for entering floats.我的 GUI 上有多个用于输入浮点数的用户输入字段。 The problem is QLineEdit brings up a cursor when you hover over the bottom of the QLineEdit box to allow you to drag and resize the box vertically.问题是当您在 QLineEdit 框的底部上方使用 hover 时,QLineEdit 会弹出 cursor 以允许您垂直拖动框并调整框的大小。

光标 结果

I would like to disable this functionality but can not find anything in the documentation that works to do this.我想禁用此功能,但在文档中找不到任何可以执行此操作的内容。

Please see a snippet of my code below -请在下面查看我的代码片段 -

self.splitter = QtWidgets.QSplitter(self.centralwidget)
        self.splitter.setGeometry(QtCore.QRect(210, 120, 137, 291))
        self.splitter.setOrientation(QtCore.Qt.Vertical)
        self.splitter.setObjectName("splitter")

self.transportField = QtWidgets.QLineEdit(self.splitter)
    self.transportField.setAlignment(
        QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
    self.transportField.setObjectName("transportField")
    self.phoneInternetField = QtWidgets.QLineEdit(self.splitter)
    self.phoneInternetField.setAlignment(
        QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
    self.phoneInternetField.setObjectName("phoneInternetField")
    self.mobileField = QtWidgets.QLineEdit(self.splitter)
    self.mobileField.setAlignment(
        QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
    self.mobileField.setObjectName("mobileField")

Any help would be greatly appreciated, or if you need to see any more code, just let me know.任何帮助将不胜感激,或者如果您需要查看更多代码,请告诉我。

self.splitter.setDisabled(True) 

This worked.这行得通。 I was originally trying to disable the QLineEdit widgets but it was the splitter that needed to be set to disabled.我最初试图禁用 QLineEdit 小部件,但它是需要设置为禁用的拆分器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM