Results 1 to 7 of 7

Thread: What to explicitely delete in qwt

  1. #1
    Join Date
    Apr 2010
    Posts
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X

    Default What to explicitely delete in qwt

    Hi,
    I use qwt to draw some plots. The widget in which I use qwt is loaded as a DLL. Everything works fine until I unload and reload the DLL.
    My feeling is that some of the allocated classes used in qwt are not propperly deleted by my code when i unload the DLL but nevertheless
    registered somewhere else in QT. This leads to a problem if the internal data structures in QT are refreshed (this is my guess..).

    So, which classes require explicit deallocation and which do not? In QT, I understood that widgets are deleted if they have a parent the moment the parent is deleted.
    In Qwt, I allocate QwtPlotCurve and attach it to the QwtPlot by using attach - does this means that QwtPlotCurve is deleted if I delete QwtPlot?
    Maybe there is a general rule which I have missed?

    Thank you and best regards

    Hauke

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


  3. #2
    Join Date
    Oct 2013
    Location
    Quebec
    Posts
    31
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: What to explicitely delete in qwt

    I was going to post the same question.

    Right now I use std::unique_ptr because I don't know if the memory is managed when you use .attach()

    Example:
    Qt Code:
    1. QwtPlotGrid *grid = new QwtPlotGrid();
    2. grid->setPen( Qt::gray, 0.0, Qt::DotLine );
    3. grid->enableX( true );
    4. grid->enableXMin( true );
    5. grid->enableY( true );
    6. grid->enableYMin( false );
    7. grid->attach( this ); //will grid pointer be deleted also?
    To copy to clipboard, switch view to plain text mode 

    In the qwt examples, it seems .attach does the memory management, because I see no delete whatsoever in the code.
    let see if we can get a confirm, it's not in the .attach documentation

  4. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: What to explicitely delete in qwt

    See: http://qwt.sourceforge.net/class_qwt_plot_dict.html. QwtPlot is derived from QwtPlotDict.

    Uwe

  5. #4
    Join Date
    Oct 2013
    Location
    Quebec
    Posts
    31
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: What to explicitely delete in qwt

    Thanks Uwe, I'll clean up my code and use raw pointers

    By the way, I don't know why Qwt isn't part of Qt framework by default? I've been using it a lot recently and it's really good!
    for example QwtSystemClock just saved my life as a reliable timer (on win and mac)

  6. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: What to explicitely delete in qwt

    Quote Originally Posted by Maximus2 View Post
    By the way, I don't know why Qwt isn't part of Qt framework by default?
    I was thinking about transfering Qwt into a Qt module, when Qt project has been started. But in the end I would end up in a development environment that is made for a large community project, that doesn't fit for my situation. Beside this I would have had to give the copyright to Nokia - today to Digia, that is trying to establish its commercial chart package.

    QwtSystemClock just saved my life as a reliable timer (on win and mac)
    Note that since Qt 4.8 QElapsedTimer is available and QwtSystemClock can be completely replaced ( internally it is using QElapsedTimer, when build for Qt >= 4.8 ).

    Uwe

  7. #6
    Join Date
    Oct 2013
    Location
    Quebec
    Posts
    31
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: What to explicitely delete in qwt

    I didn't know about QElapsedTimer, does it also use the appropriate QWT_HIGH_RESOLUTION_CLOCK depending on the OS? Anyway i'll stick to QwtSystemClock it's easy to use and does the job

    All I could say is thank you for Qwt and keeping it open! Good choice you made.
    I will use Qwt in a free and commercial application and hopefully can give you guys back when it's up and running.
    Cheers

  8. #7
    Join Date
    Apr 2010
    Posts
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: What to explicitely delete in qwt

    Hi,

    thank you for your answers and the discussion. In the meantime, I found out that my problem is caused by another issue.
    I will give the forum another post addressing that new problem.

    Best regards

    Hauke

Similar Threads

  1. Replies: 4
    Last Post: 19th February 2009, 11:10
  2. new e delete
    By mickey in forum General Programming
    Replies: 1
    Last Post: 17th July 2006, 14:11
  3. How to explicitely delete a QDir?
    By alan in forum Newbie
    Replies: 2
    Last Post: 13th February 2006, 17:48

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.