Reversing the layout of the window causes painting issues with QMenuBar



  • Basically I used the windows API to reverse the layout of the Widget Window (setLayoutDirection only changes the inner layout and does not change the layout for the titlebar). I need this so I can make a multi-language application (I need this for the Arabic languages which have reversed layouts on Windows). I have tried with Qt 4.8.4 (MSVC08, 10, MinGW). Now to explain the issue. When I reverse the layout the menubar is painted correctly, however the menus do not change their direction. For example the highlighted menu in the following picture is when I hover the mouse cursor on the left side of the window. Is this a known bug? Or did I do something wrong?

    Code: (L.E. because it is not clear in the pictures)
    @#include <QApplication>
    #include <QMenuBar>
    #include <QWidget>
    #include <QMenu>
    #include <QAction>
    #include <QLayout>
    #include <Windows.h>

    int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    QWidget *wid = new QWidget();
    QMenuBar *menuBar = new QMenuBar;
    QMenu *menu1 = new QMenu("Menu1");
    QMenu *menu2 = new QMenu("Menu2");
    QAction *act1 = new QAction("Act 1", wid);
    QAction *act2 = new QAction("Act2", wid);
    menu1->addAction(act1);
    menu2->addAction(act2);
    menuBar->addMenu(menu1);
    menuBar->addMenu(menu2);
    QVBoxLayout *lay = new QVBoxLayout;
    lay->addWidget(menuBar);
    wid->setLayout(lay);
    HWND hWnd = wid->winId();
    long extendedStyle = GetWindowLong(hWnd,GWL_EXSTYLE);
    SetWindowLong(hWnd, GWL_EXSTYLE, extendedStyle | WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT);
    wid->show();
    return app.exec();
    }

    @

    pro:
    @
    LIBS += "C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\User32.lib"

    SOURCES +=
    main.cpp
    @
    Thank you in advance.

    Pictures:

    !http://img69.imageshack.us/img69/6056/rev1k.png!

    !http://img28.imageshack.us/img28/4566/rev2e.png!

    !http://img12.imageshack.us/img12/4596/rev3n.png!



  • The MSDN library says that with the WS_EX_NOINHERITLAYOUT flag set, the children of the application shouldn't inherit the right to left layout. However this is not the case because the children inherit the layout. Is there any way to disable this using Qt? BTW setting layout direction doesn't change this weird behaviour. I am seeing the same behaviour with all widgets not just the menubar. The problem is that I don't know if it is a Qt problem or a WinAPI issue... Any help would be more than very appreciated.

    "MSDN Source":http://www.microsoft.com/middleeast/msdn/mirror.aspx



  • Basically I'm thinking of reporting this as a bug. Can anyone please tell me if I should or should not do this because I haven't reported any bugs yet and I'm not sure if I should? Thank you.




Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.