Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.4.1
-
None
-
68ab3b34571cfdde4002de9982388f9eec4d9939, Follow-up fix in Qt 5: bf178c77dda1db56ae698c1d31a6e3f685f4830f
Description
If running an application in RTL mode and dynamicly adding QActions to a QMenu when aboutToShow() is emitted. The menu will be shown incorrectly shifted to the right.
Example code:
#include <QtGui>
class BorkedMenu: public QMenu
{
Q_OBJECT
public:
BorkedMenu( QWidget *parent): QMenu(parent)
public slots:
void aboutToShow()
};
#include "main.moc"
int main( int arc, char *argv[] )
{
QApplication app(arc, argv);
app.setLayoutDirection(Qt::RightToLeft);
QMainWindow *window = new QMainWindow;
QMenu *menu;
menu = window->menuBar()>addMenu( window>tr("&File") );
menu->addAction( new QAction("New", window) );
menu->addAction( new QAction("Open", window) );
menu->addAction( new QAction("Quit", window) );
menu = window->menuBar()>addMenu( window>tr("&Edit") );
menu->addAction( new QAction("Copy", window) );
menu->addAction( new QAction("Cut", window) );
menu->addAction( new QAction("Paste", window) );
// this menu will be borked
menu = new BorkedMenu( window );
menu->setTitle("&History");
window->menuBar()->addMenu(menu);
menu = window->menuBar()>addMenu( window>tr("&Help") );
menu->addAction( new QAction("About", window) );
QTextEdit *e = new QTextEdit( window );
e->setHtml(
"<p dir='ltr'>"
"To reproduce this bug, open the History menu. The first time you open the bookmark menu, it will "
"be shifted to the right. This is because the calculation of the position of the "
"menu is done before the <b>aboutToShow()</b> signal is emmited, but many applications "
"(KDE for example) will add QActions to the QMenu on a callback method connected to this "
"signal, which means a new location need to be computed.<br><br>"
"</p>"
);
window->setCentralWidget( e );
window->showMaximized();
window->show();
return app.exec();
}
Attachments
Issue Links
- relates to
-
QTBUG-28031 QMenu right to left problem
- Closed