Results 1 to 2 of 2

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

Threaded View

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

    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 11:07. Reason: missing [code] tags

Similar Threads

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