Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Main window class vs widget class
Forum Updated to NodeBB v4.3 + New Features

Main window class vs widget class

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 17.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    geekpep
    wrote on last edited by
    #1

    Can someone please explain the detail difference between main window class and widget class in qt. While creating a project which one to choose for what ?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mohmo
      wrote on last edited by
      #2

      Main window has a status bar, menu bar and a central widget.
      the other element such as push button, label,slider and ... are widgets.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hsierra00
        wrote on last edited by
        #3

        hi
        You use the main windows class to create the body of an application.
        In case of other control push button,label etc inherit of widget, if you want create a custom view you can inherit of widget, include controls, create and implemented new functionality.

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          When working with widgets the practical choice is between QMainWindow, QWidget and QDialog.

          The QDialog choice is obvious for, well, dialogs. It includes and exec() method to start a local loop and has methods to standard dialog actions - accept and reject (ok/cancel).

          QMainWindow has features for building a main app experience. It has built-in specialized layout for housing status and tool bars. It also has a powerful docking capabilities for creating dynamic app layouts using QDockWidgets.

          QWidget is the generic choice when you don't need any of the above capabilities. This is often true for various tool windows, widgets meant to be embedded in the QDockWidgets and all the windows types that don't have rich widget-based UI eg. games or visualization windows.

          Depending on an app type there's usually a single QMainWidget used for the main app window, several smaller QWidget based windows as docks, visualization and tool windows and occasional QDialogs for "talking" to the user.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved