PDA

View Full Version : How to remove status bar from Qt 4 "Main Window" form?



jamadagni
14th January 2006, 05:14
I select "Main Window" at the "New Form" dialog in Qt 4 and I got a main window with a menubar and statusbar present by default. To remove the menubar I just right-click it and say "remove menubar". How do I remove the statusbar?

axeljaeger
14th January 2006, 13:57
Obtain a pointer to the statusbar:

http://doc.trolltech.com/4.1/qmainwindow.html#statusBar

and hide it:

http://doc.trolltech.com/4.1/qwidget.html#hide

jamadagni
14th January 2006, 14:35
Obtain a pointer to the statusbar and hide it
Thanks, but this seems a roundabout way. I think Trolltech should provide a way to do this directly, and will file a bug issue. (Why can't Qt issues be browsed, the way KDE bugs can be?)

jacek
14th January 2006, 18:16
Why can't Qt issues be browsed, the way KDE bugs can be?
Have you seen this (http://www.trolltech.com/developer/tasktracker.html)?

Matt Smith
16th January 2006, 14:37
Thanks, but this seems a roundabout way. I think Trolltech should provide a way to do this directly, and will file a bug issue. (Why can't Qt issues be browsed, the way KDE bugs can be?)

All operations on the status bar can be done through the QMainWindow class's statusBar() method, which returns a pointer to QStatusBar object, namely the window's status bar. If the window so far does not have one, it acquires one when statusBar() is called.

To display a message on the status bar, for example, you do this:

statusBar()->showMessage( "The job failed.", 2000 );

(2000 refers to the milliseconds for which the message is to appear, so 2000 represents two seconds.)

QStatusBar is a subclass of QWidget, so it inherits setVisible( bool ) and hide() from QWidget. So all you need do is:

statusBar()->hide();

or

statusBar()->setVisible( false );

See, it's not that complicated, is it?

jamadagni
17th January 2006, 04:04
All operations on the status bar can be done through the QMainWindow class's statusBar() method, it's not that complicated, is it
I quite agree, and as a programmer becomes more and more advanced there is not a thing s/he can't do through direct coding. I was just commenting that the designer did not have a way to do this while it should.

kolph
13th February 2014, 14:35
With the previous two ways to make invisible the status bar,
statusBar()->hide();
or
statusBar()->setVisible( false );

two other ways are possible :
if ( statusBar() )
delete statusBar;
or
statusBar->setMaximumHeight(0);

And, yes, what a pity that Creator (or design product) doesn't offer a simply way to avoid the status bar.

Added after 49 minutes:

The "without coding" way is, in QT creator 2.7.0, to delete the status bar item by right clicking on it, in the Object list of the design tool.