Results 1 to 3 of 3

Thread: Link QVariant to global variable

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    28
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Link QVariant to global variable

    I have list of properties. Each property has a name and a QVariant value. I can access each property over the name(like QSettings).
    I want to connect some property to a concrete global variable. If the value of property is changed the global variable should also be changed.
    Here is some code to to show what i mean.

    Qt Code:
    1. // global variable
    2. double xy; // could be any other type (e.g int,QPoint,QString etc.)
    3.  
    4. class Prop
    5. {
    6. private:
    7. QString mName;
    8. QVariant mValue;
    9. QVariant /*or void?? */ *mPointer; // should point to xy
    10.  
    11. public:
    12. void SetPointer(/*Pointer to xy*/)
    13. {
    14. mPointer = /*Pointer to xy*/;
    15. }
    16.  
    17. void SetGlobalVariabel()
    18. {
    19. // should set xy indirect with mPointer
    20. */*Pointer to xy*/ = mValue.value();
    21. }
    22. };
    To copy to clipboard, switch view to plain text mode 

    Is this possible? If yes, how can i do this.
    There are other ways to change the global variable. But also this way should work.
    Last edited by wysota; 7th May 2007 at 10:44. Reason: missing [code] tags

Similar Threads

  1. global variable
    By Shuchi Agrawal in forum General Programming
    Replies: 10
    Last Post: 15th February 2007, 04:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.