Important: Please read the Qt Code of Conduct -

How to choose Base Class?

  • Hi everyone, I want to practice some simple examples about Qt but having a tiny problem when I create a new project. I plan following "this tutorial": but I don't know which Base Class to choose, QMainWindow, QWidget, QDialog ... Its effective?

  • Hello.
    I think the best way to understand which class to use is reading of documentation for each one of these classes. There you find description and base properties of each class.
    I think QMainWindow is the best choise for project in that tutorial.

  • I wonder ... is there any sign about future program that we decide for using base class? Example inside main function:

    QWidget *window = new QWidget;

    => We use QWidget

    QDialog *dialog = new QDialog;

    => We use QDialog

    Maybe :)

  • [quote author="saobien39" date="1336962017"]I wonder ... is there any sign about future program that we decide for using base class?[/quote]
    If you don't want to hear an answer then why do you ask question?
    Also it's easy to see, that QMainWindow class was designed to be ... hm ... base for main window in applications. While QDialog is designed to be base class for different kind of dialogs. These classes have different default controlls. For example, QDialog class have only close button and help button. Of cause, you can change it, but it's silly.
    About QWidget. AFAIK it's the base class of both QMainWindow and QDialog, but if you don't need any special functionality, you don't need to use it as main window base class. Just because you're learning now. Of cause later you may do it, but now it's not reasonable.

Log in to reply