Nominate our 2022 Qt Champions!

Why use QMainwindow?

  • Hello Dears,

    i have a very general question since i´m still kind of a NewBe
    (Be* NewBe = new Be(ROFL);

    What´s the reason to use QMainwindow?
    What´s the difference compared to when i use a normal Widget, and place Dropdown and Menubuttons and arrange them by "setGeometry();"?

  • QMainWindow offer Menu bar , tools bar, status bar and can contain a center widget .

  • I'd say that QMainWindow provides you with a lot of the normal look and fell as one expects from applications. Since the list of methods not negligable compared to normal widget, it has quite some additional functionality.
    If you do not need all those functionality and look and feel, you may inherit QWidget for your class. The question is how much you have to reimplement which is already there. However, it depends heavily on your targets.

  • QMainWIndowoffers standard methods to manage MenuBar, ToolBars, StatusBar and Docks.

    IMO the most important feature is to manage them "natively" on different platform (i.e. on OSX the menu bar is on top of the screen and not in the Application Window

Log in to reply