Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Issues with translating some buttons



  • Can someone help me with this as when I select a particular language in the application, everything changes but except few buttons in the settings menu of the application but they change when i restart the application. May I know what must have i missed.

    //void ApplicationSettingsContentWidget::retranslateUi()
    {
      m_ui->retranslateUi(this);
    
      QWidget* parent = m_ButtonControlTargetLayout->parentWidget();
      Q_ASSERT(nullptr != parent);
      if(nullptr == parent) return;
    
      for(QPushButton *btn : parent->findChildren<QPushButton*>())
      {
        if(true == btn->dynamicPropertyNames().contains(QString("application_settings_button").toLatin1()))
        {
          QString name = btn->property("application_id").value<QString>();
    
          QString applicationPtrPath = getContext(Shared::GuiContexts::Type::eApplications,
                                                  CTX_APPS_CONTEXT_INSTANCES,
                                                  name,
                                                  CTX_APPS_CONTEXT_APP);
          Utilities::ApplicationPlugins::ApplicationPluginInterfacePtr
          application = getAppConfig()->query()->getAttributeValue<
                        Utilities::ApplicationPlugins::ApplicationPluginInterfacePtr>(applicationPtrPath);
    
          //only valid application instances are accepted
          if(nullptr == application) continue;
          btn->setText(application->getApplicationName());
          break;
        }
      }
    }
    

  • Qt Champions 2019

    @Nani1504 You have several if(...) in this code: did you debug to see whether any of them evaluate to false?



  • @jsulm No everything is running well. We can see in the first pic when its in english and I changed it to DE and in the third pic it can be seen that first three options changed to DE but not the other buttons.


  • Qt Champions 2019

    @Nani1504 I only see the other buttons in the first pic, in second and third they disappeared.



  • @jsulm Sorry for that, please look into them in reverse order.


  • Lifetime Qt Champion

    Hi,

    Do you have this issue on dynamically created button ?



  • @SGaist yes, all the options in the application are translating except those three buttons which we can see in the picture 1


  • Lifetime Qt Champion

    How exactly are you generating the text for them ?



  • @SGaist Actually the break statement is the reason for not allowing the 'for' loop to continue. I have removed it and everything is working fine. Thank you


Log in to reply