Qt de dialog buttonlarını Türkçeleştirme

Başlatan utabatu01, 18 Kasım 2015 - 21:53:18

« önceki - sonraki »

0 Üyeler ve 1 Ziyaretçi konuyu incelemekte.

utabatu01

Qt 5 kullanırken dialog buttonları ingilizce olarak karşıma çıkıyor bunu nasıl düzeltebilirim

mthnzbk

self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
self.buttonBox.button(QDialogButtonBox.Save).setText(self.tr("Save"))


https://github.com/mthnzbk/domestic/blob/master/domestic/dialogs/folderadd.py#L41

utabatu01


Amenofis

Formu Qt designer ile yapıyorsan sorun çıkmaması gerek. Elle ekliyorsan tr (translate) fonksiyonu içine almayı dene. buton.setText( tr("Çık")); gibi.

rutku

Bu adreste çözümü verilmiş.

buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Ok"));
buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));


Yukarıdaki kod mthnzbk ın verdiği kodla aynı  ;)
Hayallerini kodla ...

uKiriş
Mezgeldek

mthnzbk

self olayı kodu okutmuyor sanırım :D Biz  de C++ bilmiyoruz, ama sorunun çözümünü c++ kodu okuyup çözüyoruz :D

rutku

Alıntı yapılan: mthnzbk - 29 Kasım 2015 - 21:32:51
self olayı kodu okutmuyor sanırım :D Biz  de C++ bilmiyoruz, ama sorunun çözümünü c++ kodu okuyup çözüyoruz :D

Binary kod yazan gençlerden olamadık ama c/c++ geliştiricileri bizi iyi tanır diyorsun yani :D
Hayallerini kodla ...

uKiriş
Mezgeldek

rutku

Maalesef arkadaşa yanlış bilgi vermişiz. Şimdi bende kullanmak mecburiyetinde kaldım. Aşağıda doğru olan kodu veriyorum.


int uzunluk = 0;
bool tamam;
QInputDialog girdi;
girdi.setOkButtonText("Tamam");
girdi.setCancelButtonText("İptal");
girdi.setInputMode(QInputDialog::IntInput);
girdi.setLabelText("Uzunluk(cm)");
tamam = girdi.exec();
if (tamam) {
      uzunluk = girdi.intValue();
}

Hayallerini kodla ...

uKiriş
Mezgeldek

mthnzbk

Seninki asıl olan olabilir, ama benim yöntem de aynı işi görüyor. Biri method ile basitleştirmiş işi :D

rutku

Evet haklısın. Ben girdi diyalog penceresine göre anlattım. Sende buton diyalog penceresine göre anlattın. Soruyu soran arkadaş hangi diyalog penceresi için sordu şimdi kestiremedim. Neyse dursun bir kenarda ilerde başkalarının işine kesin yarar.
Hayallerini kodla ...

uKiriş
Mezgeldek

utabatu01

Öncelikli olarak verdiğiniz yöntemler için teşşekkür ederim ama hepsini denedim ama sorun çözülmedi hepsinde de hatalarla karşılaştım

rutku

Kaynak kodu paylaşırsan yardımcı olabiliriz.
Hayallerini kodla ...

uKiriş
Mezgeldek

utabatu01

cpp dosyası
#include "preferences.h"
#include <QDir>
#include <QMessageBox>
#include <QTimer>
#include <QFileDialog>
#include <QDesktopServices>


Preferences::Preferences(QWidget *parent): QDialog(parent)
{
     setupUi(this);

     settings = new QSettings(this);

     QFontDatabase db;
     foreach(int size, db.standardSizes())
       fontSizeComboBox->addItem(QString::number(size));

     kineticScrolling->setChecked(settings->value("kinetic_scrolling", false).toBool());
     sizeSpinHeight->setValue(settings->value("note_editor_default_size",QSize(335,250)).toSize().height());
     sizeSpinWidth->setValue(settings->value("note_editor_default_size",QSize(335,250)).toSize().width());


     connect(buttonBox, SIGNAL(accepted()), this, SLOT(saveSettings()));

     connect(kineticScrolling,SIGNAL(toggled(bool)),this,SIGNAL(kineticScrollingEnabledChanged(bool)));
     connect(fontSizeComboBox,SIGNAL(activated(QString)),this,SLOT(setFontSize(QString)));
}

void Preferences::setFontSize(const QString size)
{
     QFont font;
     qreal pointSize = size.toFloat();
     font.setPointSize(pointSize);
     font.setFamily(fontComboBox->currentFont().family());
     fontComboBox->setFont(font);
}

void Preferences::showEvent(QShowEvent* show_pref)
{

     rootPath = settings->value("root_path").toString();
     originalRootPath = rootPath;
     QFont font;
     font.setFamily(settings->value("note_editor_font", "DejaVu Sans").toString());
     font.setPointSize(settings->value("note_editor_font_size", 10).toInt());
     fontComboBox->setFont(font);
     fontSizeComboBox->setCurrentIndex(fontSizeComboBox->findText(QString::number
                                        (settings->value("note_editor_font_size",10).toInt())));

     QDialog::showEvent(show_pref);
}

void Preferences::saveSettings()
{
     if(!settings->isWritable())
       QMessageBox::warning(this,tr("Dikkat"),tr("Yazı ayarlanamadı!"));

     if(rootPath != originalRootPath){
       if(QMessageBox::question(this,tr("Eski çöp klasörü tutulsun mu?"),
          tr("Do you want to keep the old trash folder associated with the path %1? "
            "(You will be able to see the old files in the trash again if you change "
            "back to the previous directory.)")
          .arg(QDir::toNativeSeparators(settings->value("backup_dir_path").toString())),
          QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
       {
            QList<QFileInfo> backups = QDir(settings->value("backup_dir_path").toString()).entryInfoList(QDir::Files);
            foreach(QFileInfo backup, backups)
              QFile(backup.absoluteFilePath()).remove();
            if(!QDir().rmdir(settings->value("backup_dir_path").toString()))
              QMessageBox::warning(this,tr("Couldn't delete trash folder"), tr("Could not delete the trash folder!"));
       }

       settings->setValue("root_path",rootPath);
       pathChanged();
     }

     settings->setValue("note_editor_default_size", QSize(sizeSpinWidth->value(),sizeSpinHeight->value()));
     settings->setValue("kinetic_scrolling", kineticScrolling->isChecked());
     settings->setValue("note_editor_font", fontComboBox->currentFont().family());
     settings->setValue("note_editor_font_size", fontComboBox->font().pointSize());

     accept();
}


h dosyası#ifndef PREFERENCES_H
#define PREFERENCES_H

#include "ui_preferences.h"
#include <QSettings>
#include <QPointer>

class Preferences : public QDialog, public Ui::Preferences {
     Q_OBJECT

     public:
      Preferences(QWidget *parent = 0);
      QString rootPath;

     private:
      QSettings *settings;
      QString    originalRootPath;

     private slots:
      void setFontSize(const QString size);
      void saveSettings();


     signals:
      void pathChanged();
      void kineticScrollingEnabledChanged(bool);

     protected:
      virtual void showEvent(QShowEvent* show_pref);
};

#endif //PREFERENCES_H

buda ui <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Preferences</class>
<widget class="QDialog" name="Preferences">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>439</width>
    <height>263</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Ayarlar</string>
  </property>
  <property name="windowIcon">
   <iconset resource="../../nobleNote.qrc">
    <normaloff>:/nobleNote</normaloff>:/nobleNote</iconset>
  </property>
  <layout class="QGridLayout" name="gridLayout">
   <property name="horizontalSpacing">
    <number>10</number>
   </property>
   <item row="2" column="0" colspan="2">
    <widget class="QDialogButtonBox" name="buttonBox">
     <property name="standardButtons">
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
     </property>
    </widget>
   </item>
   <item row="1" column="0" colspan="2">
    <layout class="QGridLayout" name="gridLayout_2">
     <item row="4" column="0">
      <widget class="QFontComboBox" name="fontComboBox">
       <property name="currentFont">
        <font>
         <family>DejaVu Sans</family>
         <pointsize>10</pointsize>
        </font>
       </property>
      </widget>
     </item>
     <item row="3" column="0">
      <widget class="QLabel" name="label_5">
       <property name="font">
        <font>
         <weight>75</weight>
         <bold>true</bold>
        </font>
       </property>
       <property name="text">
        <string>Not defteri yazı tipi:</string>
       </property>
      </widget>
     </item>
     <item row="2" column="0" colspan="2">
      <layout class="QFormLayout" name="formLayout">
       <property name="sizeConstraint">
        <enum>QLayout::SetDefaultConstraint</enum>
       </property>
       <item row="0" column="0">
        <widget class="QLabel" name="label_3">
         <property name="text">
          <string>Width:</string>
         </property>
        </widget>
       </item>
       <item row="1" column="0">
        <widget class="QLabel" name="label_4">
         <property name="text">
          <string>Height:</string>
         </property>
        </widget>
       </item>
       <item row="0" column="1">
        <widget class="QSpinBox" name="sizeSpinWidth">
         <property name="maximum">
          <number>65536</number>
         </property>
         <property name="singleStep">
          <number>5</number>
         </property>
         <property name="value">
          <number>335</number>
         </property>
        </widget>
       </item>
       <item row="1" column="1">
        <widget class="QSpinBox" name="sizeSpinHeight">
         <property name="maximum">
          <number>65536</number>
         </property>
         <property name="singleStep">
          <number>5</number>
         </property>
         <property name="value">
          <number>250</number>
         </property>
        </widget>
       </item>
      </layout>
     </item>
     <item row="1" column="0" colspan="2">
      <widget class="QLabel" name="label_2">
       <property name="font">
        <font>
         <weight>75</weight>
         <bold>true</bold>
        </font>
       </property>
       <property name="text">
        <string>Varsayılan not defteri pencere boyutları:</string>
       </property>
      </widget>
     </item>
     <item row="0" column="0" colspan="2">
      <widget class="QCheckBox" name="kineticScrolling">
       <property name="toolTip">
        <string notr="true">Enables drag to scroll</string>
       </property>
       <property name="text">
        <string>dokunmatik ekran ile kaydır</string>
       </property>
      </widget>
     </item>
     <item row="4" column="1">
      <widget class="QComboBox" name="fontSizeComboBox">
       <property name="sizePolicy">
        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
         <horstretch>0</horstretch>
         <verstretch>0</verstretch>
        </sizepolicy>
       </property>
      </widget>
     </item>
    </layout>
   </item>
  </layout>
</widget>
<tabstops>
  <tabstop>kineticScrolling</tabstop>
  <tabstop>sizeSpinWidth</tabstop>
  <tabstop>sizeSpinHeight</tabstop>
  <tabstop>fontComboBox</tabstop>
  <tabstop>fontSizeComboBox</tabstop>
  <tabstop>buttonBox</tabstop>
</tabstops>
<resources>
  <include location="../../nobleNote.qrc"/>
</resources>
<connections>
  <connection>
   <sender>buttonBox</sender>
   <signal>rejected()</signal>
   <receiver>Preferences</receiver>
   <slot>reject()</slot>
   <hints>
    <hint type="sourcelabel">
     <x>174</x>
     <y>83</y>
    </hint>
    <hint type="destinationlabel">
     <x>174</x>
     <y>59</y>
    </hint>
   </hints>
  </connection>
</connections>
</ui>

rutku

Projenin tamamını gönderebilir misniz ? Güzelce rarlı bir biçimde  :D
Hayallerini kodla ...

uKiriş
Mezgeldek

7hr33l3t73r

dc -e '[q]sa[ln0=aln256%Pln256/snlbx]sb207356256404211981204295703670388snlbxq'
https://www.getgnu.org/gnulinux/gnulinux-ipuclari/nasil-akillica-soru-sorulur.html

utabatu01

evet bir proje için noblenote u çatallıyorum

Erdem


    QMessageBox ileti;
    ileti.setButtonText(QMessageBox::Yes, trUtf8("Türkçe Karakterler"));


Eğer soruyu doğru anladıysam Türkçe karakterler için trUtf8 kullanılıyor.