I have to show a find dialog which will search in a QTableView. I have the following code:
def handleFind(self):
findDialog = QDialog()
findLabel = QLabel("Find what", findDialog)
findField = QLineEdit(findDialog)
findButton = QPushButton("Find", findDialog)
#closeButton = QPushButton("Close", findDialog)
findDialog.show()
findDialog.exec_()
My problem: How to adjust the position of items in QDialog, as now closeButton overwrites findButton and findLabel and also i would like to show the buttons bellow findLable and findField. I would appreciate if you guide me in this..
---> SOLVED: By using QGridLayout:
def handleFind(self):
findDialog = QDialog()
grid = QGridLayout()
findDialog.setLayout(grid)
findLabel = QLabel("Find what", findDialog)
grid.addWidget(findLabel,1,0)
findField = QLineEdit(findDialog)
grid.addWidget(findField,1,1)
findButton = QPushButton("Find", findDialog)
grid.addWidget(findButton,2,0)
closeButton = QPushButton("Close", findDialog)
grid.addWidget(closeButton,2,1)
findDialog.show()
findDialog.exec_()
Don't use the dialog, create your own "dialog" instead. I have tried something similar to what you are trying and I found this the easiest.