Results 1 to 11 of 11

Thread: File picker

  1. #1
    Join Date
    Nov 2015
    Location
    UK
    Posts
    8
    Qt products
    Platforms
    Windows

    Default File picker

    Hi guys,

    Is there a file picker in qt designer ?? click a button and it opens a dialog that allows mw to pick a file to use in some way. I just cant find it maybe ....

    Cheers
    Steve

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: File picker

    Not in designer, but that can easily be accomplished using QFileDialog in a slot connected to a button.

    Cheers,
    _

  3. #3
    Join Date
    Nov 2015
    Location
    UK
    Posts
    8
    Qt products
    Platforms
    Windows

    Default Re: File picker

    ok cool .....got it and its now working fine .... better than I expected !!!

    so now my file loads great ... what's the best thing to use for a drop down list in qt designer ? i want to be able to display a list of data from the file we just selected ... its door entry data, we just selected the file and now want to select a name from the list created from the file we just chose .

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: File picker

    QComboBox or maybe QListView/QListWidget
    http://doc.qt.io/qt-5/widget-classes...widget-classes

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,319
    Thanks
    316
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: File picker

    Looking at some of the Qt documentation, examples, and tutorials could save you a lot of time versus asking questions here and waiting for someone to respond. Everything you have asked so far is more than adequately covered.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: File picker

    Another good starting point when looking for a widget is the widget gallery: http://doc.qt.io/qt-5/gallery.html

    Cheers,
    _

  7. #7
    Join Date
    Nov 2015
    Location
    UK
    Posts
    8
    Qt products
    Platforms
    Windows

    Default Re: File picker

    OK combobox in and working ... but.... I have two files one with the GUI stuff in it and one with the guts of the program, the main program code starts with -
    Qt Code:
    1. class MyApp(QtGui.QMainWindow, Ui_MainWindow):
    2. def __init__(self):
    3. QtGui.QMainWindow.__init__(self)
    4. Ui_MainWindow.__init__(self)
    5. self.setupUi(self)
    To copy to clipboard, switch view to plain text mode 

    does it have to start with a 'class' ?? the flow would be easier to control without it... main() doesnt really swwm to do much at all now... all the code seems to need to be in MyApp

  8. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,319
    Thanks
    316
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: File picker

    I think your "MyApp" class is a bit misnamed. It isn't the app, it is the main window for your app, and derives from QMainWindow and the Ui_MainWindow class (which is automatically generated from the Designer's .ui file - at least that's how it works in C++).

    In a C++ Qt app, this class is generally named MainWindow (or in your case, MyMainWindow). A C++ main() creates instances of QApplication and MainWindow, and then calls show() on the MainWindow instance and exec() on the app instance.

  9. #9
    Join Date
    Nov 2015
    Location
    UK
    Posts
    8
    Qt products
    Platforms
    Windows

    Default Re: File picker

    Stupid question I guess but why is it or does it have to be a class... my impression from things I have seen and read is that Class should be used for multiple instances.... there is and will only be one GUI running at once.

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: File picker

    Class has nothing to do with number of instances.

    A class defines a custom data type, a combination of data and functions working on that data.

    You are creating a subclass, a specialization of an already existing class (QMainWindow)

    Cheers,
    _

  11. #11
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,319
    Thanks
    316
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: File picker

    the flow would be easier to control without it
    The other thing to understand about Qt is that it is event-driven, like most other GUI frameworks. The control of flow through the program is in the hands of the GUI framework. Your app responds to events generated by the framework, the operating system, the user's actions, and so forth. In Qt, these are mostly divided into two types: events and signals. Things generated by the OS typically come in as the flow would be easier to control without it: paintEvent, mouseMoveEvent, keyPressEvent, etc. and the QWidget class implements default methods to handle them. Things generated by framework objects, like pushbutton clicks, timer timeouts, etc. are presented as signals. In your code, you implement slots to handle them.

    So, rather than your app controlling the flow, the Qt framework controls the flow, and your app implements (usually) short pieces of code that get executed in response to them. Nothing in your code executes except the initial startup bits in main() (and the object methods they invoke) until some event or signal occurs that you have written code to handle.

    That's why a C++ or Python program written using the Qt framework looks like a bunch of disconnected parts with no logic to hook them together, as opposed to a typical non-GUI program where your main() and the methods it calls control everything. In the Qt case, there is a flow of control, but it is embedded in the Qt event loop instead of main().

    I think of event-driven programming as like one of those marble raceways, where a half-dozen marbles are zooming around on different paths at the same time. The "control" is in the mechanism that lifts the marbles up to the starting point and lets them go; the individual raceways ("slots") do something with the marble and eventually dump the marble back at the start and wait for the next one to get dropped.

    Boy am I rambling this morning

Similar Threads

  1. Replies: 2
    Last Post: 25th February 2013, 13:32
  2. QwtPolar picker
    By slux in forum Qwt
    Replies: 5
    Last Post: 11th May 2011, 10:37
  3. Replies: 1
    Last Post: 10th May 2011, 06:29
  4. Picker text
    By MuzZviman in forum Qwt
    Replies: 1
    Last Post: 2nd June 2010, 09:49
  5. Plot Picker x=0
    By sun in forum Qwt
    Replies: 2
    Last Post: 7th October 2008, 07:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.