Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, May 2007
QMenuBar regression in Qt4.3.0rc1 ?


Message 1 in thread

Hello, Qt users !

I'm not sure if it has already been reported but I found
that menu bars are not displayed when used in subwindows.
It seems that this problem appeared in Qt4.3.0rc1 because
it works as expected with Qt4.3.0beta.

I attached a small piece of code to this mail so that people
can quickly check this on their own platform. You'll notice
that, although the menu bar is not displayed, it nonetheless
responds normally to keyboard events  (if you run my example
and press Alt+M, you should see the menu appear).

Please let me know if this problem also arises on your platform
or if I missed something. I am using Linux 2.6.21 on an i686 architecture.

Sébastien WATTEAU


----------------------------------------------------------------------
Get a free email account with anti spam protection.
http://www.bluebottle.com

#include <QApplication>
#include <QApplication>
#include <QMainWindow>
#include <QMdiArea>
#include <QMenuBar>
#include <QMenu>

class SubWindow : public QWidget {
public:
    SubWindow(QWidget* parent = 0, Qt::WindowFlags flags = 0)
        : QWidget(parent, flags)
    {
        m_menuBar = new QMenuBar(this);
        QMenu* menu = m_menuBar->addMenu(tr("&Menu"));
        menu->addAction(tr("&Action"));
    }

private:
    QMenuBar* m_menuBar;
};

class MainWindow : public QMainWindow {
public:
    MainWindow(QWidget* parent = 0, Qt::WindowFlags flags = 0)
        : QMainWindow(parent, flags)
    {
        m_centralArea = new QMdiArea(this);
        setCentralWidget(m_centralArea);
        m_centralArea->addSubWindow(new SubWindow);
    }

private:
    QMdiArea* m_centralArea;
};

int main(int argc, char* argv[])
{
    QApplication app(argc, argv);

    MainWindow win;
    win.show();

    return app.exec();
}



Message 2 in thread

Sébastien WATTEAU wrote:
> Hello, Qt users !
> 
> I'm not sure if it has already been reported but I found
> that menu bars are not displayed when used in subwindows.
> It seems that this problem appeared in Qt4.3.0rc1 because
> it works as expected with Qt4.3.0beta.
> 

We are able to reproduce the problem here. Will be fixed for 4.3.0 final.

Girish

--
 [ signature omitted ] 

Message 3 in thread

Hi,

> I attached a small piece of code to this mail so that people
> can quickly check this on their own platform. You'll notice
> that, although the menu bar is not displayed, it nonetheless
> responds normally to keyboard events  (if you run my example
> and press Alt+M, you should see the menu appear).

The problem is that the menu bar is not laid out or resized so it is 
barely visible within the sub-window.

Please apply attached patch and verify that it works as expected.


Thanks,
-- 
 [ signature omitted ] 
--- main.cpp.orig	2007-05-14 11:29:56.000000000 +0200
+++ main.cpp	2007-05-14 11:29:04.000000000 +0200
@@ -4,6 +4,9 @@
 #include <QMdiArea>
 #include <QMenuBar>
 #include <QMenu>
+#include <QLayout>
+#include <QVBoxLayout>
+#include <QTextEdit>
 
 class SubWindow : public QWidget {
 public:
@@ -13,6 +16,9 @@
         m_menuBar = new QMenuBar(this);
         QMenu* menu = m_menuBar->addMenu(tr("&Menu"));
         menu->addAction(tr("&Action"));
+        setLayout(new QVBoxLayout);
+        layout()->addWidget(m_menuBar);
+        layout()->addWidget(new QTextEdit);
     }
 
 private:

Message 4 in thread

Bjoern Erik Nilsen wrote:
> Hi,
>
>> I attached a small piece of code to this mail so that people
>> can quickly check this on their own platform. You'll notice
>> that, although the menu bar is not displayed, it nonetheless
>> responds normally to keyboard events  (if you run my example
>> and press Alt+M, you should see the menu appear).
>
> The problem is that the menu bar is not laid out or resized so it is 
> barely visible within the sub-window.
>
> Please apply attached patch and verify that it works as expected.
>
>
> Thanks,
Thanks for the patch.

I applied it and the menu bar is now displayed but it looks a bit strange...



----------------------------------------------------------------------
Get a free email account with anti spam protection.
http://www.bluebottle.com

PNG image

PNG image


Message 5 in thread

> I applied it and the menu bar is now displayed but it looks a bit strange...

Just replace "addWidget(m_menuBar);" with "setMenuBar(m_menuBar);" and 
you're fine :-)

-- 
 [ signature omitted ] 

Message 6 in thread

Bjoern Erik Nilsen wrote:
>
>> I applied it and the menu bar is now displayed but it looks a bit 
>> strange...
>
> Just replace "addWidget(m_menuBar);" with "setMenuBar(m_menuBar);" and 
> you're fine :-)
>
Yes, it works better.

I'll wait for Qt4.3.0 final and test it again once it is released :)

Thanks

----------------------------------------------------------------------
Get a free email address with REAL anti-spam protection.
http://www.bluebottle.com

--
 [ signature omitted ]