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 last edited by aha_1980
    #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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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
      2
      • mrjjM mrjj

        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 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
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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
          1
          • SGaistS SGaist

            Hi,

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

            L Offline
            L Offline
            lansing
            wrote on 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
            • mrjjM mrjj

              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 last edited by
              #6

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

              mrjjM 1 Reply Last reply
              0
              • R Rututraj

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

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on 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
                2
                • mrjjM mrjj

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

                  @mrjj Thanks :)

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Mark81
                    wrote on 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
                    0
                    • M Mark81

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