Results 1 to 12 of 12

Thread: How does qdesigner save non-QObject, such as QRect?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    8
    Thanked 18 Times in 17 Posts

    Default Re: How does qdesigner save non-QObject, such as QRect?

    Quote Originally Posted by wysota View Post
    How about writing a proper serialization mechanism using QXmlStreamReader and QXmlStreamWriter?

    There are some design patterns you might use to get a neat solution.
    I would very much appreciate If you can point me to some better solution, I am really struggling with XML things.

    Basically, I have a list of classes that contain QExplicitlySharedDataPointer. Some of the objects may be shared by several other objects. Objects are identified by name, so the requirements are that each object will have a unique name. Those objects are stored in a dictionary (a singleton dictionary global to the application), with its name as lookup key.

    I need to save the objects in the dictionary, keep the object sharing information, and I need to restore them at a later time.

    The requirements are almost the same as qdesigner, except I need shareable objects.

    Are you saying that the current method in qdesigner to save/restore ui file is the right way, that each class needs to have a corresponding Dom class, and the Dom class needs to have all the properties that the class has? It seems too much work in there. The example I have only requires a very light-weight base class, and there won't be more than a few hundreds of such objects in an application...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How does qdesigner save non-QObject, such as QRect?

    I didn't say what is the right or the wrong way of doing things. I said there is nothing wrong in the way Designer saves forms to a file. As I said, there are some design patterns you might use to delegate serialization from some external object to some other object (like the serialized class itself). If you want things to be fast, I'd advise against using XML. I'd use QDataStream instead. All you need to do then is to implement operator<< and operator>> between your class and QDataStream. See docs for details.

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.