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. [Solved: Not possible] [Question] QTabWidget: How can i add more than 1 Widget / Item to a Tab ?
QtWS25 Last Chance

[Solved: Not possible] [Question] QTabWidget: How can i add more than 1 Widget / Item to a Tab ?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.7k Views
  • 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.
  • MeerMusikM Offline
    MeerMusikM Offline
    MeerMusik
    wrote on last edited by
    #1

    Good morning.

    Currently i have the QTabWidget set as follows:

    @
    tabWidgetMainWindow = new QTabWidget(this);
    tabWidgetMainWindow->setMinimumSize(1024,768);
    tabWidgetMainWindow->addTab(LinkListe, "Linkliste");
    tabWidgetMainWindow->addTab(textEditor, "Editor");
    tabWidgetMainWindow->addTab(BrowserModule, "Browser");
    tabWidgetMainWindow->addTab(OpenAntrag, "OpenAntrag");
    tabWidgetMainWindow->show();
    @

    In Addition: I have declared a QLabel and a QLineEdit (as the Adressbar) for the BrowserModule. But how can i put these both things in the same Tab as the BrowserModule?

    I have already tested the thing with Layouts:
    Layout 1 for the Mainstuff.
    Layout 2 which only contains the QLabel and the QLineEdit.

    The Problem is: When i add Layout 2 to Layout 1, the Space between the QLabel+QLineEdit and the BrowserModule is huge (a few centimeter). If someone has a Tip how to get that Stuff centered it would be great.

    Is there a third way or do i need to go with Layouts at all? And which Layout would be advisable? Could QGridLayout be a Solution?

    I know for a Beginner it would be easier to go over the Designer: But: There is no way to learn as the Code used in the Designer is not shown in the SourceCode Files and vice versa. #MissedFeature!!
    Thanks
    Oliver

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thEClaw
      wrote on last edited by
      #2

      You can only use one widget for each tab. But you can use a simple "QWidget":http://qt-project.org/doc/qt-5/qwidget.html as a container for any number of other widgets.

      The same goes for layouts: You can have layouts within layouts. E.g. add your QLabel and QLineEdit to a "QHBoxLayout":http://qt-project.org/doc/qt-5/qhboxlayout.html (within which they are the only widgets, so there should not be a huge gap) and then add that layout to the layout that forms your tabs page.

      In most cases, "QGridLayout":http://qt-project.org/doc/qt-5/qgridlayout.html is the best one to use. Some of the others are too simple for complex widgets (QHBoxLayout, "QVBoxLayout":http://qt-project.org/doc/qt-5/qvboxlayout.html ) and some, while very useful, are made for very special purposes ("QFormLayout":http://qt-project.org/doc/qt-5/qformlayout.html , use it wherever possible, since it is extremely handy).

      About the Designer: I was in your position a couple of years ago. I have done a lot with Qt by now, but I never managed to get into the Designer after that kind of start. By now it is somewhat late, since writing things by hand is not too time-consuming, but getting to know the Designers ins and outs would be a challenge.
      I would recommend starting with the Designer as soon as possible, otherwise you create kind of an entry barrier for yourself.
      Also, there is Qt Quick, of which I know far too little. But it seems like a very good choice for creating user interfaces.

      1 Reply Last reply
      0
      • MeerMusikM Offline
        MeerMusikM Offline
        MeerMusik
        wrote on last edited by
        #3

        [quote author="thEClaw" date="1394444250"]You can only use one widget for each tab. But you can use a simple "QWidget":http://qt-project.org/doc/qt-5/qwidget.html as a container for any number of other widgets.

        The same goes for layouts: You can have layouts within layouts. E.g. add your QLabel and QLineEdit to a "QHBoxLayout":http://qt-project.org/doc/qt-5/qhboxlayout.html (within which they are the only widgets, so there should not be a huge gap) and then add that layout to the layout that forms your tabs page.

        In most cases, "QGridLayout":http://qt-project.org/doc/qt-5/qgridlayout.html is the best one to use. Some of the others are too simple for complex widgets (QHBoxLayout, "QVBoxLayout":http://qt-project.org/doc/qt-5/qvboxlayout.html ) and some, while very useful, are made for very special purposes ("QFormLayout":http://qt-project.org/doc/qt-5/qformlayout.html , use it wherever possible, since it is extremely handy).

        About the Designer: I was in your position a couple of years ago. I have done a lot with Qt by now, but I never managed to get into the Designer after that kind of start. By now it is somewhat late, since writing things by hand is not too time-consuming, but getting to know the Designers ins and outs would be a challenge.
        I would recommend starting with the Designer as soon as possible, otherwise you create kind of an entry barrier for yourself.
        Also, there is Qt Quick, of which I know far too little. But it seems like a very good choice for creating user interfaces.[/quote]

        1.) Well then my feeling was right about that. I have already played around a little by creating a Widget -> put the Stuff and different Layouts in to it. But it does not had the "Effects" i wanted - for now. I will definitely dig deeper into this.

        2.) Putting QLabel+QLineEdit in one VBoxLayout and adding it to the MainWindow Layout (HBoxLayout): Thats what i did with "Layout 1" and "Layout 2" - Not really what i wanted.

        3.) I will take a deeper look what is possible (for a Beginner) with QGridLayout.

        4.) The First things (not Apps only Tutorials) i created, were done within the Designer. But as long there is NO Way to see how the Code in the Designer looks in the SourceCode Files and vice versa, i will always prefer doing this in Code. Not really helpful if i never learn what i have to write / code :)

        BTW: I first created the above Stuff in the Designer and after that, i decided to create everything in the SourceCode Files.

        I simply prefer to have total control over the Stuff i do. I really wish they would add this Feature in the very near Future.

        But yes, i will create Stuff first in the Designer just to see / learn what is possible. After that: I will do the Stuff i tried / created in Code. For me and my schizophrenic Brain, the best way to go for now.

        Thanks and have a good Day :)
        Oliver

        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