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:
↧