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. Runtime Translation of Multiple Inheritance Approach Dialog
Qt 6.11 is out! See what's new in the release blog

Runtime Translation of Multiple Inheritance Approach Dialog

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 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.
  • D Offline
    D Offline
    DrQuade
    wrote on last edited by
    #1

    Hi i have the Problem of how to access the retranslateUI() function of an Dialog which i setup using the multiple Inheritance Approach:

    my headerfile looks like this

    @#ifndef SERVICESCREEN_H
    #define SERVICESCREEN_H
    #include "ui_servicemenu.h"

    class myservicemenu : public QDialog, public Ui::servicemenu
    {
    Q_OBJECT

    public:
    myservicemenu(QDialog *parent = 0);

    protected:

    public slots:
    void on_pushButton_clicked();

    private slots:

    };

    #endif // SERVICESCREEN_H@

    Constructor like this:
    @myservicemenu::myservicemenu(QDialog *parent) : QDialog(parent)
    {
    setupUi(this);

    }@

    now i want to access from the change Event in Mainwindow the retranslateUI() from my designer generated Ui_servicemenu, but i don't know how to achieve this.

    @void MainWindow::changeEvent(QEvent* event)
    {
    if (event->type() == QEvent::LanguageChange)
    {
    //Here i wanna call the retranslateUi() of my servicemenu form
    ui.retranslateUi(this);//<--this retranslates Mainwindow

    }
    QMainWindow::changeEvent(event);
    }@

    The retranslation of the MainWindow works but i also want to retranslate the servicemenu Dialog anyone has an advice?
    thx in advance

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      Hi,

      did you load the translations for Qt? You have to add a second QTranslator object and load the Qt translation files.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DrQuade
        wrote on last edited by
        #3

        Hi, yes i did, i used te Example i found "here":http://www.qtcentre.org/wiki/index.php?title=Dynamic_translation_in_Qt4_applications and added my own new Dialog called servicemenu

        When i add an extra changeEvent like:
        @void myservicemenu::changeEvent(QEvent* event)
        {

        if (event->type() == QEvent::LanguageChange)
        {
                 retranslateUi(this);
        
        }
        

        }@

        all my Dialogs get Translated but when i have a lots of Dialogs (>100) i need a change event for every Dialog instead of handling all in one Mainwindow::changeEvent?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          You have to do it in every dialog I think.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          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