Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Reversing the layout of the window causes painting issues with QMenuBar
Forum Updated to NodeBB v4.3 + New Features

Reversing the layout of the window causes painting issues with QMenuBar

Scheduled Pinned Locked Moved General and Desktop
4 Posts 1 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    b1gsnak3
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      b1gsnak3
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • B Offline
        B Offline
        b1gsnak3
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          b1gsnak3
          wrote on last edited by
          #4

          Filled in a bug: "QTBUG-29349":https://bugreports.qt-project.org/browse/QTBUG-29349

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved