所以我一直在尝试做的是生成一个小部件列表,将它们添加到网格布局,然后将它们添加到选项卡并呈现给用户.我现在遇到的问题是网格布局跨越每个标签的整个页面,但我没有添加那么多行,因此行最终跨越整个页面而不会对齐到顶部.我尝试设置alignment和verticalSpacing,但没有一个改变了小部件的显示方式.
例如:
我希望小部件显示如下:
WidgetName WidgetLabel
WidgetName WidgetLabel
WidgetName WidgetLabel
WidgetName WidgetLabel
Run Code Online (Sandbox Code Playgroud)
相反,我得到这个:
WidgetName WidgetLabel
WidgetName WidgetLabel
WidgetName WidgetLabel
WidgetName WidgetLabel
Run Code Online (Sandbox Code Playgroud)
有没有办法强制所有元素到达顶部或任何所需的方向?
我试图将按钮信号连接到我创建的可调用信号,但由于某种原因,此错误不断弹出.我已经检查过确保导入了QtCore ...我还缺少什么?
示例代码:
from PyQt4 import QtCore
from PyQt4 import QtGui
import sys
class guiFindFiles(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
#Create window
self.setFixedSize(400,180)
self.setWindowTitle("Choose the files to use")
#Create all layouts to be used by window
self.windowLayout = QtGui.QVBoxLayout()
self.fileLayout1 = QtGui.QHBoxLayout()
self.fileLayout2 = QtGui.QHBoxLayout()
self.fileLayout3 = QtGui.QHBoxLayout()
#Create the prompt for user to load in the q script to use
self.qFileTF = QtGui.QLineEdit("Choose the q script file to use")
self.qFileButton = QtGui.QPushButton("Open")
self.qFileButton.setFixedSize(100,27)
self.fileLayout1.addWidget(self.qFileTF)
self.fileLayout1.addWidget(self.qFileButton)
#Connect all the signals …Run Code Online (Sandbox Code Playgroud)