I think adding it using the find child should work. I am not only trying to adding a QPushButton but also add a QTextEdit to show the user more information about the file.
Thanks, - Adam On Thursday, 15 November 2018 00:35:19 UTC-5, Justin Israel wrote: > > QFileDialog is a composite widget, which already has its own layout and > children. When you call setLayout, you are replacing the existing one with > your own. This causes all of the existing widgets to lose their layout > constraints. If you want to add more widgets, then you will have to work > with the existing layout and child widgets. What kind of arrangement are > you looking for with your new push button? There may be a better way to do > it instead of messing with the layout, such as modifying the > QDialogButtonBox: > > buttonBox = self.findChild(QtWidgets.QDialogButtonBox) > # add button and wire up signal to something > > On Thu, Nov 15, 2018 at 4:58 PM Adam Baker <[email protected] > <javascript:>> wrote: > >> >> >> Hey all, >> >> I am trying to add a QPushButton or any other QWidget to a QFileDialog. >> >> Here is where I currently am: >> >> >>> *from PySide2 import QtWidgets, QtCore, QtGui**class >>> fileOpen(QtWidgets.QFileDialog):* >>> >>> * def __init__(self):* >>> * super(fileOpen, self).__init__()* >>> * self.setWindowTitle("ATK Open File")** >>> self.setObjectName('ATKOpenFile')* >>> * self.buildUI()* >>> >>> * def buildUI(self):* >>> * btnLayout = QtWidgets.QHBoxLayout()* >>> * self.setLayout(btnLayout)* >>> * btn = QtWidgets.QPushButton('Click')** >>> btnLayout.addWidget(btn)* >>> >>> >>> *def showUI():* >>> * ui = fileOpen()* >>> * ui.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)* >>> * ui.show()** return ui* >> >> >> >> The problem is that the button now takes up the while window and the >> QFileDialog gets pushed to the upper corner collapsing on it's self. >> >> Thanks >> Adam >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Python Programming for Autodesk Maya" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/1633c52d-e9ce-4b4c-b09b-d4298883baf4%40googlegroups.com >> >> <https://groups.google.com/d/msgid/python_inside_maya/1633c52d-e9ce-4b4c-b09b-d4298883baf4%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/149bc1b1-a649-4fa5-bce2-566f8a00c1d5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
