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. [SOLVED]--QProperty's International
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]--QProperty's International

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 3.6k 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.
  • P Offline
    P Offline
    poppw
    wrote on last edited by
    #1

    Hello,
    I'm trying to use Meta-Object System to build a property editor like Qt Designer.

    I declare a Q_Property thing like this
    @Q_PROPERTY(QString myText READ getTextWRITE setText DESIGNABLE true)@
    in a class.

    I think I make DESIGNABLE true so that the property myText can be visible in the property editor.

    But the question comes when I try to show this property ,myText ,in another language.I have no idea about making the name of the very property, myText , to be shown in Japanese etc.

    i.e. In the declaration
    @ Q_PROPERTY(type name READ getFunction WRITE setFunction DESIGNABLE true@
    can name be translated into another language in a GUI?
    Where should I put tr()?

    Thanks!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      The only option I see is to add a method to the class and do it there. Properties are typically a developement thing so they are in english only. The only one (in a generic approach) who could translate it is the class, so add something like:

      @
      class CFoo
      {
      Q_PROPERTY(QString myText READ getText WRITE setText DESIGNABLE true)
      Q_PROPERTY(QString name READ getText WRITE setText DESIGNABLE true)
      public:
      // ...
      public slots:
      QString translatePropertyName(QString szName, QString targetLanguage);
      }
      @

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        The Q_PROPERTY macros serve only as a marker for moc and pre-processes out of the code for the compiler: so you cannot put executable code in there. The names must also be constructed of single byte characters suitable for use in a C-style string because that is what moc and QMetaObject does with them.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          poppw
          wrote on last edited by
          #4

          Thank you. It seems to work.
          [quote author="Gerolf" date="1340263596"]The only option I see is to add a method to the class and do it there. Properties are typically a developement thing so they are in english only. The only one (in a generic approach) who could translate it is the class, so add something like:

          @
          class CFoo
          {
          Q_PROPERTY(QString myText READ getText WRITE setText DESIGNABLE true)
          Q_PROPERTY(QString name READ getText WRITE setText DESIGNABLE true)
          public:
          // ...
          public slots:
          QString translatePropertyName(QString szName, QString targetLanguage);
          }
          @[/quote]

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

            I extended YAPE (to be found on qtapps.org) once to support these and other additional options. I ended up adding an optional special property to the objects I wanted to show. For every property that I had additional attributes for, I'd create a (dynamic) property <PropertyName>attributes, that contained a QVariantHash with additional attributes. Such properties included the editor name (to get a non-standard editory like a file name selector for a QString property), placeholder text in the editor, limits for valid value ranges, tooltips, etc.

            Code is available under LGPL if you are interested.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              alexpux
              wrote on last edited by
              #6

              [quote author="Andre" date="1346920355"]

              Code is available under LGPL if you are interested.[/quote]

              Can you give a code of extended YAPE?

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                Look for srtools on assembla.com (currently down, so I can't give you a direct link right now).

                Then in the repository, find common/propertyeditor/

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  alexpux
                  wrote on last edited by
                  #8

                  Seems I found it. Thanks!
                  https://www.assembla.com/code/srtools/git/nodes/addressTool/common/propertyeditor
                  But it show me only properties-flags.
                  Will investigate more.
                  Also no attributes for valid value ranges.

                  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