Issue
I have created a gridlayout review GUi window. I added title,author,review labels and LineEdit along with Quit button at the bottom. When i execute the script the quit button is not showing in the output window.
import sys
from PySide import QtGui,QtCore
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
title = QtGui.QLabel('Title')
author = QtGui.QLabel('Author')
review = QtGui.QLabel('Review')
titleEdit = QtGui.QLineEdit()
authorEdit = QtGui.QLineEdit()
reviewEdit = QtGui.QTextEdit()
btn = QtGui.QPushButton("Quit", self)
btn.resize(50,50)
btn.clicked.connect(QtCore.QCoreApplication.instance().quit)
grid = QtGui.QGridLayout()
grid.setSpacing(10)
grid.addWidget(title, 1, 0)
grid.addWidget(titleEdit, 1, 1)
grid.addWidget(author, 2, 0)
grid.addWidget(authorEdit, 2, 1)
grid.addWidget(review, 3, 0)
grid.addWidget(reviewEdit, 3, 1, 5, 1)
grid.addWidget(btn,6,1)
self.setLayout(grid)
self.setGeometry(300, 300, 350, 300)
self.setWindowTitle('Review')
self.show()
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
I couldn't find out what is the issue . Where i am doing wrong??
Solution
Change grid.addWidget(btn, 6, 1)
to grid.addWidget(btn, 8, 1)
. Your QTextEdit
has height 5
in grid units; therefore 3 + 5 = 8
is first empty spot.
Answered By - Matphy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.