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] Programm internal scripting language
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Programm internal scripting language

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.0k 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.
  • N Offline
    N Offline
    Nobody-86
    wrote on last edited by
    #1

    Hi,

    I would like to implement a scripting method for faster user input. This should be like programm specific internal programming, oder a kind of Macro.

    examples:

    • AutoCAD: the user can draw a line by clicking two point or by typing "line, x1, y1, x2, y2"
    • gnuplot: changing the label by clicking in the menu "Axis / X Label" or typing "set xlabel 'abc'".

    I guess there is a smarter way than do thomething like this:
    @switch(line){
    case "abc": methodABC(); break;
    case "def": mathodDEF(); break;
    }@

    because, this structure will blow up, if there are a lot of methods available.

    1 Reply Last reply
    0
    • JKSHJ Online
      JKSHJ Online
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      What's your question?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Nobody-86
        wrote on last edited by
        #3

        Hi,
        I want to know if there is a better way to find the function to call than a giant switch case statement.

        Maybe there is a way to parse the input line (string) to the functions name, and call the function or something like that.

        1 Reply Last reply
        0
        • JKSHJ Online
          JKSHJ Online
          JKSH
          Moderators
          wrote on last edited by
          #4

          One way is to use a map to store a list of allowed input strings, and map it to function pointers: http://stackoverflow.com/questions/2136998/using-a-stl-map-of-function-pointers (the examples use std::map, but you can use a "QMap":http://qt-project.org/doc/qt-5.0/qtcore/qmap.html ). Then, use the input string as the key to retrieve the function to call.

          However, the map technique can't easily handle functions that have different parameter types. A more flexible way is to use Qt's meta-object system -- this also lets you look up function names using strings. Read the documentation for "QMetaMethod":http://qt-project.org/doc/qt-5.0/qtcore/qmetamethod.html and "QMetaObject":http://qt-project.org/doc/qt-5.0/qtcore/qmetaobject.html. Your functions need to be member functions of a QObject.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • N Offline
            N Offline
            Nobody-86
            wrote on last edited by
            #5

            Hi,

            it looks like QMap do what I need. The map example is also very nice. I guess I can use it for my purpose.

            Thanks for your help JKSH!

            1 Reply Last reply
            0
            • JKSHJ Online
              JKSHJ Online
              JKSH
              Moderators
              wrote on last edited by
              #6

              You're welcome :) Please edit your original post an add "[SOLVED]" to the title!

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              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