Results 1 to 2 of 2

Thread: PaintEvent() in a dynamically created and destroyed objet not working.

  1. #1
    Join Date
    May 2010
    Posts
    100
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default PaintEvent() in a dynamically created and destroyed objet not working.

    hi,

    i am trying to set transparency using QPainter:aintEvent(QPaintEvent *event), for dynamic widget which is created and destroyed at run time .

    My code is like this:

    Qt Code:
    1. DynamicWidget::DynamicWidget(QSignalMapper *lsig, QWidget *parent)
    2. {
    3. widget =new QWidget();
    4. widget.setGeoMetry(0,0,480,800);
    5.  
    6. label1=new QLabel(widget);
    7. label2=new QLabel(widget);
    8. label3=new QLabel(widget);
    9. line1=new QLineEdit(widget);
    10.  
    11. //Rotate widget using QGraphicsView and QGraphicsScene
    12. widget.setParent(this);
    13. //embedding widget into a view and scene
    14. view.show();
    15. }
    16.  
    17. DynamicWidget::paintEvent(QPaintEvent *event)
    18. {
    19. qDebug("paint event occured");
    20. QPainter painter(this);
    21. //Draw rectangle of GeoMetry(0,0,480,800)
    22. //setOpacity(0.5);
    23. }
    24.  
    25.  
    26. DynamicWidget::~DynamicWidget()
    27. {
    28. delete label1;
    29. delete label2;
    30. delete label3;
    31. delete line1;
    32. delete view;
    33. delete scene;
    34.  
    35. delete widget;
    36.  
    37. }
    To copy to clipboard, switch view to plain text mode 

    /*****************End******************/

    Code gets compiled and when i run ,i can see DynamicsWidget once when the DynamicsWidget created, and later on it not showing anything.

    I am delete DynamicsWidget at the interval of 3 seconds. Can't i take QPainter painter(this), no.of times. This is working nicely on Static object for other classes.

    what could be the problem?
    Last edited by wysota; 20th October 2010 at 10:07. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: PaintEvent() in a dynamically created and destroyed objet not working.

    i can see DynamicsWidget once when the DynamicsWidget created, and later on it not showing anything.
    What does "later on" mean?
    when does it disappear?
    Can you show relevant code that creates and uses the widget?

    And PLEASE, use the code tags when posting code.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. QMainWindow ignores dynamically created, floating QDockWidget
    By stefanadelbert in forum Qt Programming
    Replies: 1
    Last Post: 2nd March 2010, 01:06
  2. Replies: 2
    Last Post: 20th September 2009, 02:52
  3. Destroyed while process is still running
    By qtzcute in forum Qt Programming
    Replies: 5
    Last Post: 23rd July 2009, 08:26
  4. Object destroyed, what about connections?
    By Caius Aérobus in forum Qt Programming
    Replies: 1
    Last Post: 7th July 2008, 17:41
  5. [Qt 4.1.3] Child widget not destroyed
    By Dusdan in forum Qt Programming
    Replies: 13
    Last Post: 24th May 2006, 08:17

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.