Results 1 to 7 of 7

Thread: templates / Q_OBJECT question

Threaded View

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

    Default Re: templates / Q_OBJECT question

    I think you can avoid templates. Why not using only a factory class + an abstract(basically for preventing instantiating this meaningless class) node class + node implementations?
    The factory class will return Node(abstract) objects which you could identify later by adding a getType pure virtual method which subclasses actually implement.

    For example:
    Qt Code:
    1. AbstractNode *node = NodeFactory.CreateNode...;
    2. switch(node->type())
    3. {
    4. ...
    5. case AbstractNode::eTypeANode:
    6. {
    7. dynamic_cast<TypeANode*>(node)->SomeTypeANodeSpecializedMethod();
    8. break;
    9. }
    10. ...
    11. }
    To copy to clipboard, switch view to plain text mode 

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

    _borker_ (19th December 2007)

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.