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. How do I add a statusbar widget to a dialog in the ui designer?

How do I add a statusbar widget to a dialog in the ui designer?

Scheduled Pinned Locked Moved Solved General and Desktop
qstatusbarpromote
10 Posts 6 Posters 17.3k 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.
  • L Offline
    L Offline
    lansing
    wrote on 4 Aug 2018, 14:32 last edited by aha_1980 8 Apr 2018, 15:06
    #1

    I have a well established dialog ui and I want to add a status bar to the bottom. But apparently there is no QStatusBar to choose from in the tool box. And there is no option to promote a class to QStatusBar.

    I have tried the trick told on link stackoverflow to add a dummy widget first then manually change the object to use QStatusBar class in the generated ui header file. But the problem is every time I make a change in the designer again and try to run it, it will change back to the dummy class.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 4 Aug 2018, 14:47 last edited by
      #2

      Hi
      Well its only possible via code.
      You simply insert in after setupUI() been run in constructor
      QStatusBar *bar = new QStatusBar(this);
      ui->somelayout->addWidget(bar);

      Often you need a layout to keep it to the bottom but sounds like you
      already have that.

      L R 2 Replies Last reply 4 Aug 2018, 15:48
      2
      • M mrjj
        4 Aug 2018, 14:47

        Hi
        Well its only possible via code.
        You simply insert in after setupUI() been run in constructor
        QStatusBar *bar = new QStatusBar(this);
        ui->somelayout->addWidget(bar);

        Often you need a layout to keep it to the bottom but sounds like you
        already have that.

        L Offline
        L Offline
        lansing
        wrote on 4 Aug 2018, 15:48 last edited by
        #3

        @mrjj

        Thanks it works. I added a layout to the bottom of the ui, and then in my cpp file I added the statusbar to the layout and it showed up. But somehow it's still not sticking to the bottom.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 4 Aug 2018, 19:27 last edited by
          #4

          Hi,

          What kind of layout do you use in your widget ? How are you using it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          L 1 Reply Last reply 5 Aug 2018, 05:26
          1
          • S SGaist
            4 Aug 2018, 19:27

            Hi,

            What kind of layout do you use in your widget ? How are you using it ?

            L Offline
            L Offline
            lansing
            wrote on 5 Aug 2018, 05:26 last edited by
            #5

            @SGaist

            Hi i fixed the problem. It was caused by one of the initial functions in my cpp that outputed a layout onto the ui, which has not been constrained by the layout of the main widget.

            1 Reply Last reply
            1
            • M mrjj
              4 Aug 2018, 14:47

              Hi
              Well its only possible via code.
              You simply insert in after setupUI() been run in constructor
              QStatusBar *bar = new QStatusBar(this);
              ui->somelayout->addWidget(bar);

              Often you need a layout to keep it to the bottom but sounds like you
              already have that.

              R Offline
              R Offline
              Rututraj
              wrote on 9 Mar 2020, 10:13 last edited by
              #6

              @mrjj How to access this statusbar for showing message or adding a progressbar

              M 1 Reply Last reply 9 Mar 2020, 11:07
              0
              • R Rututraj
                9 Mar 2020, 10:13

                @mrjj How to access this statusbar for showing message or adding a progressbar

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 9 Mar 2020, 11:07 last edited by
                #7

                @Rututraj
                Hi
                well an easy way is just to use a member variable.

                so instead of
                QStatusBar *bar = new QStatusBar(this); // local variable

                we do
                bar = new QStatusBar(this); // memeber variable

                and in .h (in the class) we have
                QStatusBar *bar = nullptr; // moed to be a member

                and then you can just use bar-> to talk to it.

                R 1 Reply Last reply 9 Mar 2020, 11:37
                2
                • M mrjj
                  9 Mar 2020, 11:07

                  @Rututraj
                  Hi
                  well an easy way is just to use a member variable.

                  so instead of
                  QStatusBar *bar = new QStatusBar(this); // local variable

                  we do
                  bar = new QStatusBar(this); // memeber variable

                  and in .h (in the class) we have
                  QStatusBar *bar = nullptr; // moed to be a member

                  and then you can just use bar-> to talk to it.

                  R Offline
                  R Offline
                  Rututraj
                  wrote on 9 Mar 2020, 11:37 last edited by
                  #8

                  @mrjj Thanks :)

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Mark81
                    wrote on 17 Nov 2023, 14:28 last edited by
                    #9

                    After 5 years it is still not possible to populate the status bar from the designer?

                    Christian EhrlicherC 1 Reply Last reply 17 Nov 2023, 14:46
                    0
                    • M Mark81
                      17 Nov 2023, 14:28

                      After 5 years it is still not possible to populate the status bar from the designer?

                      Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on 17 Nov 2023, 14:46 last edited by
                      #10

                      @Mark81 Feel free to provide a patch :)

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      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