Seite 1 von 1

2 Fragen, Resourcen und retranslateUi()

Verfasst: 7. Mai 2010 15:09
von SaLu
Hallo habe 2 Fragen die ich einfach nicht gelöst bekomme. Zu ersteinmal will ich die Sprache wechseln und je nach Sprache soll ein anderes Bild kommen.
Die resource Datei sieht wie folgt aus.

Code: Alles auswählen

<RCC>
    <qresource prefix="/prefix1" lang="de">
        <file>fahne_de.gif</file>
    </qresource>
    <qresource prefix="/prefix2" lang="gb">
        <file alias="fahne_de.gif">fahne_gb.gif</file>
    </qresource>
</RCC>
laut beschreibung sollte es so gehn. So das Problem ist ja noch das ich einem QLabel sagen muss welche datei er nimmt. Also so in etwa.

Code: Alles auswählen

label_3->setStyleSheet(QString::fromUtf8("background-image: url(:/prefix2/fahne_de.gif);"));
ja leider ist das QT Tutorial sehr dürftig darüber und mehr steht nicht drin. Weiß einer was ich noch ändern muss?

------------------

2 Frage. ich rufe in meinem Programm ui.retranslateUi(this) auf. dies dürfte ja kein problem sein. Die GUI wurde mit dem Designer erstellt und die ui_x.h wird automatisch generiert. Die Funktion

Code: Alles auswählen

 void retranslateUi(QWidget *SpracheClass)
    {
        SpracheClass->setWindowTitle(QApplication::translate("SpracheClass", "Sprache", 0, QApplication::UnicodeUTF8));
        label->setText(QApplication::translate("SpracheClass", "Sprache", 0, QApplication::UnicodeUTF8));
        label_2->setText(QString());
        comboBox->clear();
        comboBox->insertItems(0, QStringList()
         << QApplication::translate("SpracheClass", "Deutsch", 0, QApplication::UnicodeUTF8)
         << QApplication::translate("SpracheClass", "Englisch", 0, QApplication::UnicodeUTF8)
        );
        label_3->setText(QString());
    } // retranslateUi
bei diesem aufruf stürzt er jedesmal ab. Warum?

Vielen Dank im vorraus schonmal

Verfasst: 7. Mai 2010 15:54
von Christian81
Was it an
Some resources, such as translation files and icons, many need to change based on the user's locale. This is done by adding a lang attribute to the qresource tag, specifying a suitable locale string. For example:

<qresource>
<file>cut.jpg</file>
</qresource>
<qresource lang="fr">
<file alias="cut.jpg">cut_fr.jpg</file>
</qresource>

If the user's locale is French (i.e., QLocale::system().name() returns "fr_FR"), :/cut.jpg becomes a reference to the cut_fr.jpg image. For other locales, cut.jpg is used.

See the QLocale documentation for a description of the format to use for locale strings.
nicht zu verstehen?

Zur zweiten Frage - das hatten wir heute schon einmal - für Abstürze gibt es einen Debugger...