2

I'm trying to create an opening screen for my software. Because I have a status bar in the QMainwindow then Qt makes me a transparent line line at the bottom of the opening screen.

I tried using:

this-> statusBar () -> hide ();
ui-> statusBar-> hide ();

But for some reason Qt ignores them and still show me the transparent line at the bottom of the screen.

I can not remove the status line completely because I used it on the next screen later.

How can I just hide it?

ymoreau
  • 3,402
  • 1
  • 22
  • 60
YOKO
  • 119
  • 1
  • 7
  • 1
    I've tried and it works, maybe it's another widget, try the following code: `ui->statusBar->showMessage("some message"); ui->statusBar->hide();`, If you do not see the message then it is another widget. – eyllanesc Dec 02 '17 at 20:11
  • Have you tried [`ui->setStatusBar(nullptr)`](http://doc.qt.io/qt-5/qmainwindow.html#setStatusBar). But be careful with regard to ownership of the existing `QStatusBar`. – G.M. Dec 02 '17 at 20:12
  • @G.M. He wants to hide the statusbar, he does not want to eliminate it. – eyllanesc Dec 02 '17 at 20:14
  • 1
    By opening screen do you mean a splash screen? If yes, [QSplashScreen](http://doc.qt.io/qt-5/qsplashscreen.html) would be more appropriate than QMainWindow. – scopchanov Dec 03 '17 at 01:42
  • @eyllanesc when i do `ui->statusBar->showMessage("some message");` i can see this massage on the transperent line , when i do `ui->statusBar->showMessage("some message"); ui->statusBar->hide();` i don't see the massage but i still see the transperent line – YOKO Dec 03 '17 at 15:58
  • i add phtos , this is the transperent line after the `hide` : `https://ibb.co/iv8BLG` this is the transperent without the `hide` : `https://ibb.co/grJYZb` – YOKO Dec 03 '17 at 16:03
  • @scopchanov no i mean the QMainWindow – YOKO Dec 03 '17 at 16:28
  • QSplashScreen can show messages too, but I presume you have a reason to go with QMainWindow instead. In any case @eyllanesc is right - there must be something else since the message could be hidden successfully. A couple of suggestions: 1. Share more info about the design of your window in order to keep the people from guessing. At best prepare a minimal example - that always help to track down problems. 2. Include the links to the images from your comment in the question so they could be easily seen/clicked. – scopchanov Dec 03 '17 at 16:42

3 Answers3

4

You can remove both the status bar and menu bar without editing the .ui file.

In Qt Designer or Creator, in the widget tree, find the status bar, right-click it and select "Remove" in the context menu.

Remove status bar in context menu

The same can be done with the menu bar.

Ronan Paixão
  • 8,297
  • 1
  • 31
  • 27
3

I tried to use statusbar()->hide() from code, and that didn't solve my specific problem which was that the real estate for the statusbar still existed on the dialog, and also in the UI Designer.

My solution: Manually edit the myview.ui file and remove the line:

<widget class="QStatusBar" name="statusbar"/>

That solved it: no more status bar. (since I didn't want it there, this worked for me)

Doug
  • 131
  • 6
2
QMainWindow::setStatusBar(nullptr);

You can also use 'this' instead of 'ui'

this->statusbar()->hide();

Alternative: this->statusbar()->setVisible(false);

Ui is the form itself, 'this' is the MainWindow widget. Statusbar() is a member of MainWindow, not the Ui form. You cannot access ui->MainWindow directly, In class MainWindow, access its members with 'this->'.