Problems with program settings after using "retranslateUi"

  • Hello,
    when i use "retranslateUi" i saw that all my setting are not kept.
    In the automatically generated file " ....form.h" i saw this:
    goCTOP__combo__Language->insertItems(0, QStringList()
    << QApplication::translate("laytab_optionen", "deutsch", 0)
    << QApplication::translate("laytab_optionen", "englisch", 0) );

    I think the ->clear() is the problem.
    The only way to avoid the reset of all comboboxes is to save/restore all regarding setting before/after
    i call "retranslateUi". Is this correct, or is there an automatism i don't see?

  • Lifetime Qt Champion

    All text must be set again. Titles and text in items so
    it will clear any selected item etc for a combobox.

    save/restore all regarding setting

    Im not sure what setting u loose besides the currently selected?

  • @mrjj
    Thank you for your answer.
    The problem ist, i have a big application with a lot of settings. I load them at start and save them at end.
    Now if i change the language, many settings (not only comboboxes) are changed.
    For me that's a problem.
    Even when i am changing the translation combo from "deutsch" to the second value (englisch) , retranslateUi resets it to first item and display "german".
    Not very intelligent, in my opinion. I thought (hoped), Qt remembers the usage of the texts and changes them on the fly.
    I solved the problem i that way, that the user has to restart the application.
    Much to much hand work for a little more comfort.

  • Lifetime Qt Champion

    Why not just reload the settings after language change?

  • @jsulm
    yes, of course, but that solves not this problem:

    • when the combos are cleared and reset, sometimes other funktions are called and there could be side effects. e.g. some lists are depending on combobox-setting. Yes, i have same problem on startup, but there's is still a difference.
      And mabybe my app is not so good programmed that it should be
    • I should call many init-functions. till now i call them only at startup. may be side effects like described.
    • mostly i don't use QtDesigner but QGridlayout and my text settings are not so well separated from all other than i need it for this function. Often i set fixed texts with the "new" statement for the widget.
    • i saw that "retranslateUi" changed even labels, which store a filename, where i don't used tr() at all. I think the tr() comes from QtDesinger, but i didn't look deeper.
      i sum to many changes.

    To translat the app is very necessary and for me surprisingly easy in qt. To change language on the fly is only nice but costs much more than translation itself. so i save the this work and invest in some more features.

Log in to reply