The above code produces the following output − Self.btn1 = QPushButton("QFileDialog object") Self.btn = QPushButton("QFileDialog static method demo") Super(filedialogdemo, self)._init_(parent) ![]() The contents of the selected file are displayed in the TextEdit widget. The second button invokes the file dialog by calling exec_() method on QFileDialog object. The selected image file is displayed on a label widget. The first button invokes the file dialog by the static method.įname = QFileDialog.getOpenFileName(self, 'Open file', Enumerated constants are −ĭisplays only those files having mentioned extensionsīoth methods of invoking the file dialog are demonstrated in the following example. ![]() Uses the file name selected by the user to save the fileĭetermines whether the file box acts as open or save dialog Returns name of the file selected by the user to open it Important methods and enumerations of QFileDialog class are listed in the following table − Sr.No. The starting directory and default file name can also be set. Static functions of QFileDialog class ( getOpenFileName() and getSaveFileName()) call the native file dialog of the current operating system.Ī file filter can also applied to display only files of the specified extensions. The dialog is invoked either through static functions or by calling exec_() function on the dialog object. ![]() ![]() It enables the user to navigate through the file system and select a file to open or save.
0 Comments
Leave a Reply. |