How can I add widgets to my QFileDialog instance?

You can use the layout() [doc.qt.nokia.com] function to get hold of the dialog’s layout and add
your widgets there. See the following example:

  1.     #include <QtGui>
  2.  
  3.     int main(int argc, char **argv)
  4.     {
  5.         QApplication app(argc, argv);
  6.         QFileDialog box;
  7.         QPushButton *button = new QPushButton(&box);
  8.         button->setText("New button");
  9.         QGridLayout *layout = (QGridLayout*)box.layout();
  10.         layout->addWidget(button, 0, 0);
  11.         box.show();
  12.         return app.exec();
  13. }
  14.  

1 comment

November 14, 2011

Picture of ququmber ququmber

Lab Rat

This doesn’t work for native QFileDialog, for example with kde4. But starting work after specifying QFileDialog::DontUseNativeDialog option.

Write a comment

Sorry, you must be logged in to post a comment.