Skip to content
  • 0 Votes
    3 Posts
    2k Views
    beeckscheB

    @Wieland
    Thanks for the informations!

    In the Surface Example they only delete the Q3DSurface instance.

    But i will pass the parents to the classes, so i can be sure, that they are destroyed. Thanks!

  • 0 Votes
    4 Posts
    7k Views
    kshegunovK

    @alogim
    Hello,
    Unfortunately, no. To make use of the parent-child mechanism your object must derive from QObject at least. Search through the forum for "QObject" and "RAII", Here is a thread where I've put some effort in explaining the QObject ownership. Back to your question:

    class Object : public QObject { public: Object(QWidget * parent = 0) : QObject(parent) { } };

    Will do what you want, i.e. delete the Object when the parent is destroyed. Then you indeed create your object like this:

    Object * obj = new Object(this);

    and it's sufficient to ensure proper cleanup.

    Kind regards.

  • 0 Votes
    10 Posts
    10k Views
    mbruelM

    I'm having a new problem when I move a second QTcpSocket inside the thread.
    Everything seems to work fine but the thread is crashing (segmentation fault) after deletion (after receiving the destroyed signal). It seems to be an desallocation issue... I couldn't manage to figure out the problem yesterday and today...
    I'm going to write a easier example of my architecture and open a new post.
    Cheers

  • 0 Votes
    4 Posts
    2k Views
    S

    @SGaist said:

    Hi,

    @SysTech : deleteLater won't remove things when the thread is done, but at the next event loop iteration.

    Thanks. I wasn't exactly sure when it deleted it but good to know!