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 991 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.
  • M mpergand

    @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 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
    0
    • I ixion

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

      M Offline
      M Offline
      mpergand
      wrote on last edited by mpergand
      #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
      0
      • M mpergand

        @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 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
        0
        • I ixion

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

            @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 last edited by mpergand
            #8

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

            I 1 Reply Last reply
            0
            • M mpergand

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

              I Offline
              I Offline
              ixion
              wrote on last edited by
              #9

              @mpergand QSize(204, 32)

              M 1 Reply Last reply
              0
              • I ixion

                @mpergand QSize(204, 32)

                M Offline
                M Offline
                mpergand
                wrote on 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 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
                  0
                  • I ixion

                    @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 last edited by mpergand
                    #12

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

                    JonBJ 1 Reply Last reply
                    0
                    • M mpergand

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

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #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
                      0
                      • JonBJ JonB

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

                        • Login

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