QFileDialog from within a class

  • Probably a stupid question, since I am at a primitive level of understanding...
    I have created a class like this:




    and instantiate it in MainWindow. I want to call QFileDialog() within one of the QVideoOutput member functions,
    but I have not been able to figure out what the first argument (QWidget *parent) should be. Various choices of awidget
    corresponding to GUI widgets fail, causing the program to crash. Obviously there is something fundamentally wrong with
    what I'm doing. I'd appreciate helpful advice.


  • Moderators

    You need to pass the pointer of your QMainWindow to it (or from any other widget). If you don't have it at hand, you can simply pass 0 (zero).

    You can also make your QMainWindow into a Singleton (this is a programming construct, search the Web for more info) and then use it in your class. There are many options :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.