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. Is using a QTabWidget for the "main" window a good idea?
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.4k 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.
  • D Offline
    D Offline
    Deneuve
    wrote on last edited by
    #1

    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;
    window.show();

    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)?

    Thanks!

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

      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...

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Deneuve
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Deneuve
          wrote on last edited by
          #4

          Nobody has any advice?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              Deneuve
              wrote on last edited by
              #6

              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!

              1 Reply Last reply
              0

              • Login

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