Results 1 to 2 of 2

Thread: Date sharing among instances of different classes with QSharedDataPointer?

  1. #1
    Join Date
    Sep 2009
    Location
    Aachen, Germany
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Date sharing among instances of different classes with QSharedDataPointer?

    Hi.

    This might be considered a general c++ question, I hope you don't mind.

    What I want:
    I have a set of about 10 different classes which are all part of a quite complex QDialog. These classes need access to several, certain QStrings, ints and bools. I definitely don't want to pass these values around between the classes.

    So far:
    I started out by putting those values in a container to which I then passed around a pointer. But that's just a little less ugly version of passing around the values directly, and still very ugly.

    So today I got rid of the pointer and made those values static. I'm not that familiar with static members. As far as I understand they're initiated when the application is started, even though my dialog may never be openend, and are only deleted when de application is closed, right?

    What about QSharedDataPointer? Might that be a better alternative? Does it work among different classes?

  2. #2
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Date sharing among instances of different classes with QSharedDataPointer?

    I got rid of the pointer and made those values static
    If you can make those values static, why not to use QSharedPointer?

Similar Threads

  1. Classes with Implicit Sharing
    By weaver4 in forum Newbie
    Replies: 5
    Last Post: 15th January 2011, 18:57
  2. Replies: 9
    Last Post: 29th August 2010, 14:30
  3. How to correctly subclass classes that use implicit sharing
    By Gh0str1d3r in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2010, 09:42
  4. QSharedDataPointer and Data with virtual functions
    By niko in forum Qt Programming
    Replies: 0
    Last Post: 2nd February 2010, 08:23
  5. Replies: 4
    Last Post: 17th October 2009, 22:31

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.