Changing layout



  • hi to every one
    i wrote a program that has two language
    one of them should be right to left
    i want to change my layout when it is selected
    how can i do that?
    i use this code but it doesnt work
    @QApplication::setLayoutDirection(Qt::RightToLeft);@



  • QApplication::setLayoutDirection() doesn't affect already instantiated widgets.

    You need to call setLayoutDirection in your main() function like this

    @int main(int argc, char** argv)
    {
    QApplication app(argc, argv);
    app.setLayoutDirection(Qt::RightToLeft);
    // show stuff
    return app.exec();
    }@

    However, if you want to change the layout direction after your QApplication has been execed you need to install a new QTranslator and retranslteUi() your UI.

    See "this email thread":http://lists.qt.nokia.com/pipermail/qt-interest/2011-May/033798.html for more information and example code.


Log in to reply
 

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