Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Howto define global variables ?
Forum Updated to NodeBB v4.3 + New Features

Howto define global variables ?

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 6.8k 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
    pascal95abc
    wrote on last edited by
    #1

    Hello,

    can some one explain me how to declare global variables in my Qt Quick Application ?

    I use "this template":http://doc.qt.nokia.com/qtmobility-1.2/qml-positionsource.html#details

    Thank you

    Qt 4.7.3
    Symbian OS v9.4 / Symbian^1, S60 5th Edition
    on N97

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      Hello,

      Can you explain a bit more? What do you mean by "global variable"?

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      1 Reply Last reply
      0
      • P Offline
        P Offline
        pascal95abc
        wrote on last edited by
        #3

        I mean a variable that can be accessed (read and modified) by every function.

        For example in Delphi, these have to be declared at the very beginning.

        Qt 4.7.3
        Symbian OS v9.4 / Symbian^1, S60 5th Edition
        on N97

        1 Reply Last reply
        0
        • T Offline
          T Offline
          task_struct
          wrote on last edited by
          #4

          Take a look at "this":http://doc.qt.nokia.com/4.7-snapshot/qdeclarativescope.html#component-instance-hierarchy

          "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

          • Linu...
          1 Reply Last reply
          0
          • P Offline
            P Offline
            pascal95abc
            wrote on last edited by
            #5

            So, is it @property <data type> <variable name>@ ?

            And then, how can I change the value e.g.

            @ Item {
            id: root
            property string title

            ...

            string = string + "xyz"

            onClick { string = string + "abc" }

            }@

            ?

            Qt 4.7.3
            Symbian OS v9.4 / Symbian^1, S60 5th Edition
            on N97

            1 Reply Last reply
            0
            • T Offline
              T Offline
              task_struct
              wrote on last edited by
              #6

              You can change the value on some event ( line onClicked ), when state changes with ( "PropertyChanges":http://doc.qt.nokia.com/4.7-snapshot/qml-propertychanges.html ) or during transitions using animations.

              "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

              • Linu...
              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