python - PyQt4 将 LineEdit 拉伸到窗口宽度
问题描述
我想将 QLineEdit 小部件拉伸到窗口宽度。
这是带有要拉伸的小部件的代码 <---HERE
import sys
from PyQt4.Qt import *
# Create the QApplication object
qt_app = QApplication(sys.argv)
class HWApp(QWidget):
''' Basic Qt app'''
def __init__(self):
# Initialize the object as a QLabel
QWidget.__init__(self) #, "Hello, world!")
# Set the size, alignment, and title
self.setMinimumSize(QSize(800, 600))
self.setWindowTitle('Hello, world!')
self.tbox = QLineEdit("simple text",self)#<---HERE
self.setAlignment(Qt.AlignCenter)
def run(self):
''' Show the app window and start the main event loop '''
self.show()
qt_app.exec_()
# Create an instance of the app and run it
HWApp().run()
必须添加什么才能将其拉伸到整个窗口宽度并使其与窗口保持可伸缩性?
解决方案
推荐阅读
- selenium - 运行 Chrome 时忽略跨域 Chrome 策略
- docusignapi - Docusign 自定义按钮和 Salesforce 联系人角色
- r - 如何在ggplot2的轴上绘制单个值?
- r - 使用 cbind 将向量与向量列表绑定
- java - 如何在运行时检查当前的 java 类路径
- dafny - 在 BubbleSort 证明中我错过了什么不变量?
- javascript - 获取所有子元素的 id
- swift - AlamoFire.Request 中的多个参数
- c# - 使用 Simple Injector 注入 IUrlHelper
- node.js - nvm 没有获得最新版本