您如何自定义PYQT5文本框
我一直在尝试自定义文本框以尝试看起来像这样并尝试格式化文本,但是到目前为止,我还没有奏效,所以我恢复了基本代码:
self.tbx = QLineEdit(self)
self.tbx.resize(400,75)
layout.addWidget(self.tbx)
layout.addStretch()
I have been trying to customised the text box to try and look like this and trying to format the text but so far nothing has worked so i have reverted back to the base code :
self.tbx = QLineEdit(self)
self.tbx.resize(400,75)
layout.addWidget(self.tbx)
layout.addStretch()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用QGroupBox,然后在QGroupbox中添加QlineEdit。
您可以自定义QGroupbox具有一个圆角和QlineDit,以具有透明的背景,并且使用@Kalzso提到的样式表没有边框。
以下是一个示例:
文件mainwindow.py(由pyuic5生成):
和主文件:
给出:
我的解决方案的限制:
,我的解决方案中QlineIt的光标是与颜色相比的,而您想要的可能是白色光标。我发现我很难解决这个问题。我发现这个答案可能有助于改变光标的颜色。也许有人可以帮助改善此答案并解决此问题。
You can using a QGroupBox, and add the QLineEdit inside the QGroupBox.
You can customize the QGroupBox to have a round corner and the QLineEdit to have a transparent background and no border using stylesheets mentioned by @kalzso.
The following is an example:
File MainWindow.py (generated by pyuic5):
And the main file:
Which gives:
Limitation of my solution:
However, the cursor of the QLineEdit in my solution is of contrasting color, while what you want may be a white cursor. I find it difficult for me to solve this. I find this answer may help to change the color of the cursor. Maybe someone can help to improve this answer and solve this problem.