Results 1 to 6 of 6

Thread: How to Map member variables with Qt Widgets?

  1. #1
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up How to Map member variables with Qt Widgets?

    Hi all,

    I want to map some member variables with Qt Widgets . For example i have 2 QLineEdit contrtols for hours and minutes , I want to update currosponding members whenever these 2 widgets are getting changed , Is there any mechanism in Qt to do this?
    Thanks,
    Rajesh.S

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to Map member variables with Qt Widgets?

    Yeah, what about signals and slots?

  3. #3
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to Map member variables with Qt Widgets?

    How to achieve this using signals and slots?
    Thanks,
    Rajesh.S

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to Map member variables with Qt Widgets?

    Connect the line edit's textChanged signal to a slot in your class and in there just assign the new text to the member variable.
    The signal will get emitted each time the text changes.

  5. The following user says thank you to marcel for this useful post:

    rajeshs (18th December 2007)

  6. #5
    Join Date
    Jun 2007
    Location
    India/Bangalore
    Posts
    156
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: How to Map member variables with Qt Widgets?

    Thank you for your valuable reply,

    Is there any other straight mechanism to do this?
    Thanks,
    Rajesh.S

  7. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to Map member variables with Qt Widgets?

    Quote Originally Posted by rajeshs View Post
    Thank you for your valuable reply,

    Is there any other straight mechanism to do this?
    Well, this is the most easiest one.
    You could also try QSignalMapper if you have a lot of line edits, but it is also based on signal/slots.

  8. The following user says thank you to marcel for this useful post:

    rajeshs (18th December 2007)

Similar Threads

  1. Qt3 - Multiple transparent widgets
    By bythesea in forum Qt Programming
    Replies: 4
    Last Post: 11th September 2009, 11:24
  2. widgets behind hidden widgets not working
    By bpetty in forum Newbie
    Replies: 13
    Last Post: 7th September 2007, 20:23
  3. Performance in hiding/showing widgets
    By Paalrammer in forum Newbie
    Replies: 12
    Last Post: 14th February 2007, 18:57
  4. Replies: 11
    Last Post: 7th July 2006, 13:09
  5. Creating Widgets
    By hylke in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2006, 08:37

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.