[Qt-interest] Toggle visibility of a QMainWindow's menu bar?

Andreas Diehl krokodiehl at t-online.de
Sun Jan 11 16:57:04 CET 2009


Oh sorry, that was a mistake. I forgot to change the topic name. Damn 
copy&paste ...

But to your problem with the QMenubar I can tell you, that I've tested it 
(with Qt 4.4.2) and menuBar()->hide() worked as well as menuBar()->show().
I tried it wihtin my QMainWindow class itself using
    this->menuBar()->hide();
so perhaps it doesn't work from outside or your window doesn't have any 
menubar at the point you want to hide it?
Perhaps check how you create your menubar. My example code is:

public class MyWindow extends QMainWindow
{
    public MyWindow()
    {
        super();
        buildLayout();
        buildActions();
        buildMenu();
    }

    ...

    private void buildMenu()
    {
        QMenu fileMenu = this.menuBar().addMenu("File");
        fileMenu.addAction( loadAction);
        //and so on
    }

    protected void slotHideMenubar()
    {
        this.menuBar().hide();
    }

    protected void slotShowMenubar()
    {
        this.menuBar().show();
    }
}

I know it's Java code, but C++ should look very similar. Note that I don't 
use any newly created QMenuBar.

----- Original Message ----- 
From: "R. Reucher" <rene.reucher at batcom-it.net>
To: <qt-interest at trolltech.com>
Sent: Sunday, January 11, 2009 4:20 PM
Subject: Re: [Qt-interest] Toggle visibility of a QMainWindow's menu bar?


> On Sun January 11 2009 16:14:10 Andreas Diehl wrote:
>> I have got a problem with a QPixmap and a QLabel. I'd like to show an 
>> image
>> using QLabel:
> Sorry, I can't help you on this, but why are you posting on my thread's 
> topic
> when it's not related to it? Please post a new topic...
>
> Regards, René
> -- 
> René Reucher
> rene.reucher at batcom-it.net
> http://www.batcom-it.net/
>
> "I appreciate the fact that this draft was done in haste, but some of
> the sentences that you are sending out in the world to do your work for
> you are loitering in taverns or asleep beside the highway."
> -- Dr. Dwight Van de Vate, Professor of Philosophy,
>    University of Tennessee at Knoxville
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>


--------------------------------------------------------------------------------



No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.176 / Virus Database: 270.10.5/1886 - Release Date: 10.01.2009 
18:01




More information about the Qt-interest-old mailing list