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?
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?
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
It's nice to be important but it's more important to be nice.
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?)Originally Posted by axeljaeger
Have you seen this?Originally Posted by jamadagni
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.Originally Posted by jamadagni
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?
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.Originally Posted by Matt Smith
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.
Last edited by kolph; 13th February 2014 at 13:35.
Bookmarks