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. QUrl no translatable
Qt 6.11 is out! See what's new in the release blog

QUrl no translatable

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.5k 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.
  • A Offline
    A Offline
    Alnorte
    wrote on last edited by
    #1

    Hi.

    I'm creating my own plugin, and it has a property of QUrl type . When I compiling some element of this type in .ts file is appears as translatable, someone can tell me how you can use a QUrl with no translation option?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Just don't translate it.

      More seriously, though, QUrl should not be translatable by default - make sure you are not using tr() or QObject::tr() somewhere in your code when setting the QUrl.

      (Z(:^

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Alnorte
        wrote on last edited by
        #3

        Hi and good morning.

        I think the first post does not have enough information.

        I'm working with Qt 4.7.4 and I'm creating my own plugin.

        my plugin has a QUrl property and I never use tr() options so I think that the translate option is default.

        this is the plugin code
        pruebaplugin.cpp in the domXml() I establish the qurl variable like no translatable.

        pruebaplugin.cpp
        @
        ...
        QString PruebaPlugin::domXml() const
        {
        QString str;

        str=QString("<ui language="c++">\n"
        " <widget class="Prueba_%1" name="Prueba_%1">\n"
        " <property name="geometry">\n"
        " <rect>\n"
        " <x>0</x>\n"
        " <y>0</y>\n"
        " <width>50</width>\n"
        " <height>50</height>\n"
        " </rect>\n"
        " </property>\n"
        " <property name="path" >\n"
        " <string notr="true"></string>\n"
        " </property>\n"
        " <property name="toolTip" >\n"
        " <string></string>\n"
        " </property>\n"
        " <property name="whatsThis" >\n"
        " <string></string>\n"
        " </property>\n"
        " </widget>\n"
        "</ui>\n").arg(PLG_VRS);

        return str;
        }
        ...@

        <property name="path" >
        <string notr="true"></string> <--- notr=true

        prueba.h
        @class QDESIGNER_WIDGET_EXPORT Prueba_0 : public QWidget
        {
        Q_OBJECT

        Q_PROPERTY(QUrl path READ path WRITE setPath RESET resetPath)
        

        public:
        ...
        Private:
        QUrl my_path;
        @

        prueba.cpp
        @
        ...
        void PRUEBA::setPath(const QUrl &newPath) {
        my_path=newPath;
        }
        QUrl PRUEBA::path() const {return my_path;}
        void PRUEBA::resetPath() {my_path.clear();}
        ...
        @

        when I use this plugin in the main app and when execute the lupdate the qurl variable appears in the .ts file.

        What I'm doing wrong

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Looking at your code, I don't see any reason why it should pop up in .ts file.

          However inconvenient that may be, you can simply leave the string untranslated (then it will not change when you switch the language), or remove the offending line from .ts file (it's a simple XML file).

          (Z(:^

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Alnorte
            wrote on last edited by
            #5

            Thank for answer me.

            I have another question that has relation with the Q_PROPERTY and the translations.
            I have other variable like QString and it works properly while don't use the reset option. The QString objects in properties has a subproperties with translatable, disambiguation and comment option. I define this options disable in the domXml function, notr=true, but if it use the reset option(the arrow that it's in the right part of the variable) always appears on, can I control it? or can I disabled this arrow option?

            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