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. QWidget with QTabWidget
Forum Updated to NodeBB v4.3 + New Features

QWidget with QTabWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 971 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.
  • I Offline
    I Offline
    ixion
    wrote on 5 Apr 2023, 21:39 last edited by
    #1

    Hi all. Please tell me why when adding a tab widget, the main widget does not expand automatically?

    Снимок экрана от 2023-04-06 00-33-44.png l

    ? M 2 Replies Last reply 5 Apr 2023, 22:39
    0
    • I ixion
      5 Apr 2023, 21:39

      Hi all. Please tell me why when adding a tab widget, the main widget does not expand automatically?

      Снимок экрана от 2023-04-06 00-33-44.png l

      ? Offline
      ? Offline
      A Former User
      wrote on 5 Apr 2023, 22:39 last edited by
      #2

      @ixion I may be wrong but as far as I know size policy works only for widgets put inside layout. The last line is a do nothing line as 'this' is not child of any layout (and it cannot be). Best thing to do I think is to set main widget size manually.

      1 Reply Last reply
      0
      • I ixion
        5 Apr 2023, 21:39

        Hi all. Please tell me why when adding a tab widget, the main widget does not expand automatically?

        Снимок экрана от 2023-04-06 00-33-44.png l

        M Offline
        M Offline
        mpergand
        wrote on 5 Apr 2023, 22:46 last edited by
        #3

        @ixion
        Add this method:

        QSize sizeHint() const override
            {
                return QSize(500,400);
            }
        

        Or resize your widget after show():
        widget.resize(500,400);

        I 1 Reply Last reply 5 Apr 2023, 22:50
        0
        • M mpergand
          5 Apr 2023, 22:46

          @ixion
          Add this method:

          QSize sizeHint() const override
              {
                  return QSize(500,400);
              }
          

          Or resize your widget after show():
          widget.resize(500,400);

          I Offline
          I Offline
          ixion
          wrote on 5 Apr 2023, 22:50 last edited by
          #4

          @mpergand thanks, but I can't make the widget resize automatically depending on the objects inside it?

          M 1 Reply Last reply 5 Apr 2023, 22:56
          0
          • I ixion
            5 Apr 2023, 22:50

            @mpergand thanks, but I can't make the widget resize automatically depending on the objects inside it?

            M Offline
            M Offline
            mpergand
            wrote on 5 Apr 2023, 22:56 last edited by mpergand 4 May 2023, 22:57
            #5

            @ixion
            Try:
            tableWidget->resize(500,400);
            If it doesn't work try to set a fixed or a minimum size instead.

            I 1 Reply Last reply 5 Apr 2023, 23:02
            0
            • M mpergand
              5 Apr 2023, 22:56

              @ixion
              Try:
              tableWidget->resize(500,400);
              If it doesn't work try to set a fixed or a minimum size instead.

              I Offline
              I Offline
              ixion
              wrote on 5 Apr 2023, 23:02 last edited by
              #6

              @mpergand said in QWidget with QTabWidget:

              ni

              thanks, I know about resize, I'm interested in the automatic resizing of the widget, without explicitly specifying the size

              ? M 2 Replies Last reply 5 Apr 2023, 23:05
              0
              • I ixion
                5 Apr 2023, 23:02

                @mpergand said in QWidget with QTabWidget:

                ni

                thanks, I know about resize, I'm interested in the automatic resizing of the widget, without explicitly specifying the size

                ? Offline
                ? Offline
                A Former User
                wrote on 5 Apr 2023, 23:05 last edited by
                #7

                @ixion without being in a layout, as far as I know, there's nothing. I think you will have either to live with your main widget not risizing automatically, or implement that auto resize by yourself (by adding the width of all tabs + some constant should be what you need).

                1 Reply Last reply
                0
                • I ixion
                  5 Apr 2023, 23:02

                  @mpergand said in QWidget with QTabWidget:

                  ni

                  thanks, I know about resize, I'm interested in the automatic resizing of the widget, without explicitly specifying the size

                  M Offline
                  M Offline
                  mpergand
                  wrote on 5 Apr 2023, 23:06 last edited by mpergand 4 May 2023, 23:17
                  #8

                  @ixion
                  I don't think it works with a tabWidget ...
                  What size is return by tabWidget->sizeHint() ?

                  I 1 Reply Last reply 5 Apr 2023, 23:12
                  0
                  • M mpergand
                    5 Apr 2023, 23:06

                    @ixion
                    I don't think it works with a tabWidget ...
                    What size is return by tabWidget->sizeHint() ?

                    I Offline
                    I Offline
                    ixion
                    wrote on 5 Apr 2023, 23:12 last edited by
                    #9

                    @mpergand QSize(204, 32)

                    M 1 Reply Last reply 5 Apr 2023, 23:16
                    0
                    • I ixion
                      5 Apr 2023, 23:12

                      @mpergand QSize(204, 32)

                      M Offline
                      M Offline
                      mpergand
                      wrote on 5 Apr 2023, 23:16 last edited by
                      #10

                      @ixion said in QWidget with QTabWidget:

                      @mpergand QSize(204, 32)

                      Seems close to the image you post.
                      In the Designer try with different size policies and see if it changes something.

                      1 Reply Last reply
                      0
                      • I Offline
                        I Offline
                        ixion
                        wrote on 6 Apr 2023, 04:41 last edited by
                        #11

                        @ankou29666 said in QWidget with QTabWidget:

                        without being in a layout, as far as I know, there's nothing. I think you will have either to live with your main widget not risizing automatically, or implement that auto resize by yourself (by adding the width of all tabs + some constant should be what you need).

                        thanks

                        M 1 Reply Last reply 6 Apr 2023, 11:34
                        0
                        • I ixion
                          6 Apr 2023, 04:41

                          @ankou29666 said in QWidget with QTabWidget:

                          without being in a layout, as far as I know, there's nothing. I think you will have either to live with your main widget not risizing automatically, or implement that auto resize by yourself (by adding the width of all tabs + some constant should be what you need).

                          thanks

                          M Offline
                          M Offline
                          mpergand
                          wrote on 6 Apr 2023, 11:34 last edited by mpergand 4 Jun 2023, 11:39
                          #12

                          Actually, the default behaviour is not the same between MacOs and Linux !

                          JonBJ 1 Reply Last reply 6 Apr 2023, 12:45
                          0
                          • M mpergand
                            6 Apr 2023, 11:34

                            Actually, the default behaviour is not the same between MacOs and Linux !

                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on 6 Apr 2023, 12:45 last edited by JonB 4 Jun 2023, 12:45
                            #13

                            @mpergand
                            I have only used Qt on Linux. My impression was that it never auto-grows a top-level window, at least when you put more content into it, i.e. like the left-hand one. Maybe it only does that window-widening under MacOS?

                            M 1 Reply Last reply 7 Apr 2023, 12:16
                            0
                            • JonBJ JonB
                              6 Apr 2023, 12:45

                              @mpergand
                              I have only used Qt on Linux. My impression was that it never auto-grows a top-level window, at least when you put more content into it, i.e. like the left-hand one. Maybe it only does that window-widening under MacOS?

                              M Offline
                              M Offline
                              mpergand
                              wrote on 7 Apr 2023, 12:16 last edited by
                              #14

                              @JonB said in QWidget with QTabWidget:

                              I have only used Qt on Linux. My impression was that it never auto-grows a top-level window, at least when you put more content into it, i.e. like the left-hand one.

                              Since on linux, the length of the tab titles are not taken into account, the overall size of the tab widget reflects the widest element present in the tab pages.

                              On mac, the minimum size of the tab widget depends of the length of the tab titles.
                              Otherwise the tab titles are troncated with ellipsis, very ugly.

                              1 Reply Last reply
                              0

                              1/14

                              5 Apr 2023, 21:39

                              • Login

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