3

I am making my first steps with Qt. As an exercise, I am writing a GUI for a many-core processor, and individual cores are shown in a separate window. From this window, there may be several copies, with their independent life, including menus, status line, etc. That is, they are essentially like a QMainWindow, but having a QMoreMainWindow :). Might be any side effect if I use QMainWindow several times?

rubenvb
  • 74,642
  • 33
  • 187
  • 332
katang
  • 2,474
  • 5
  • 24
  • 48

2 Answers2

4

Nothing prevents you from using any of them for anything. They do have different roles and properties:

  • QMainWindow is just that: a main window. It has a toolbar, dockwidgets, a menu bar, a status bar, and a central widget. If you don't need all (most of) those things, you clearly don't want a QMainWindow.
  • QWindow is a barebones object in which is useful if you don't want/need QWidget's functionality.
  • QDialog is meant to be used for pop-up windows (i.e. "dialogs") like a messagebox or an open file dialog.
  • QWidget is the basic window or window element. If in doubt, use this.

Reading your question, it seems you want each of those windows to be a QMainWindow. Note I'd still prefer a custom QWidget with only the parts I needed if I were you. Adding a statusbar and menu isn't that much code.

rubenvb
  • 74,642
  • 33
  • 187
  • 332
1

multiple main windows is no issue at all. I also use them in my application and they work fine. You can either have the main windows separately (no parent) or dependant on some main mainwindow, so that they are closed when the main mainwindow is closed.

When your main windows have independent lives and menus, status lines etc., this speaks even more for multiple main windows that probably should all have no parent assigned.

So, yes, your approach seems perfectly fine to me.

IceFire
  • 4,016
  • 2
  • 31
  • 51