Is using a QTabWidget for the "main" window a good idea?

  • Hi,

    I'm creatig a "big" program, and I'd like to know if using a QTabWidget for the main window is a good idea.

    That means that the main window class will inherit QTabWidget and its constructor will call the QTabWidget constructor. Same as using a QWidget for the main window, but a QTabWidget instead.

    Plus, that means in the main function, I would write:

    MyTabWidget window;;

    Is that a good idea or I should better just use a classical QWidget for the main window and add a QTabWidget in it (with a layout for example)?


  • I would rather inherit from QMainWindow and then add a QTabWidget to that window, as you might want to have a menu bar and/or a status bar too. Not sure if that would be (easily) possible with only a QTabWidget...

  • Thanks for answering!

    Actually I don't think I need a menu/status/toolbar. The main interface is composed of tabs, and everything's in it. So that's why I was wondering if it may be a good idea to directly inherint the main window from QTabWidget rather than QWidget.

  • Nobody has any advice?

  • First, practice some patience. It is not acceptable to "kick" your topic within 12 hours. Two days seems to be a bare minimum to wait.

    Then: what kind of advice do you really expect? You're not telling us much about your application, and then you ask if a choice on a specific issue is the best one. How should we know?

    In general: I'd think that it is probably not a good idea. I'd keep my options open to redesign in the future. That can be done by no inheriting from QTabWidget, but to use encapsulation instead. You offer the API your main widget needs to offer, and implement it terms of the embedded QTabWidget. Then, if you need to change your design later on, you can do that by just focusing on the main widget itself, instead of hunting all over your app to find where you used or abused the fact that your main widget used to be a QTabWidget.

  • Sorry about the early up.

    So, for the context. I'm developing an accounting desktop application. The main window, which is the first interface you see after opening the program, will only be composed of tabs. I've not planned to use any toolbar, menu bar or status bar. All the other widgets will be in the QTabWidget. That's why I was wondering if it wasn't a good idea to directly make inherit my main window by QTabWidget, instead of QMainWindow or QWidget as usual. Because if I use a QWidget, that means I'll just have to put in it a QTabWidget, and nothing else, which is not really usefull...

    Am I precise enough? Thanks for help!

Log in to reply

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