Results 1 to 8 of 8

Thread: Problem with dynamic_cast

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Problem with dynamic_cast

    Quote Originally Posted by vratojr
    I APPEND other elements and I creat new widgets,nothing else.
    Each time I create an element, I set the position variable and create the widget. nothing more.
    I add that,for what I see, I got errors only after creating the first widget. I mean, the first is ok,the others may be wrong.
    When you add elements to a QVector (or std::vector), it sometimes must allocate more space for new elements and to achieve that it might have to move all elements to another place in the memory. If this happens, all pointers to previous elements will be invalid.

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

    vratojr (12th April 2006)

  3. #2
    Join Date
    Jan 2006
    Location
    La Spezia,Italy
    Posts
    77
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    9
    Thanked 5 Times in 5 Posts

    Default Re: Problem with dynamic_cast

    Argh!Yeah! I've read this just some days ago...
    Thank you very much!

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Problem with dynamic_cast

    You can either reserve enough space before you add elements (if you know their exact number) or use a vector of pointers.

Similar Threads

  1. Very strange socket programming problem
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2008, 12:05
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.