Próbuję utworzyć ten geometery:qt GridLayout obejmujących wiele kolumn
_ ___
| | |
|1| 3 |
|_|___|
|_2_|
Jeżeli pole 1 jest wysoki i chudy, skrzynka 2 jest krótki i szeroki. Nie mogę poprawnie odczytać układu. Kiedy rozwijam opcje rowSpan i columnSpan dla 1 i 2 z 0 na 1, widzę dolne pole we właściwej względnej lokalizacji, ale wysokość jest błędna, a szerokość pola 1 jest niepoprawna.
To tak qq pomógł ale nie w pełni rozwiązać mój problem: How to arrange the items in QGridLayout as shown?
import sys
from PyQt4 import QtGui
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
textEdit1 = QtGui.QTextEdit("LHS rectangle")
textEdit2 = QtGui.QTextEdit("Bottom rectangle")
textEdit3 = QtGui.QTextEdit("Central square")
self.gridLayout = QtGui.QGridLayout()
self.gridLayout.addWidget(textEdit1, 0, 0, 2, 0)
self.gridLayout.addWidget(textEdit2, 2, 1, 0, 2)
self.gridLayout.addWidget(textEdit3, 0, 1, 2, 2)
self.setLayout(self.gridLayout)
self.show()
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Spróbuj wymienić 0 o 1 w wierszu, rozpiętość ("textEdit1,0, 2,2,1") – Mel
@tmoreau Na moim komputerze dodaje niewielką ilość widżetu textEdit2 powyżej textEdit3 zamiast poniżej textEdit3. –