Results 1 to 11 of 11

Thread: Refresh problem with QPaintEvent

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Refresh problem with QPaintEvent

    I've created a dummy updater(singleshot timer, to update after few seconds) to update to new values.
    Now I don't know whr to call updateGraph() function. I've done something like this, but it's not updating the graphs.
    Can you give some sample code to handle this pls.

    Qt Code:
    1. Dialog::Dialog(QWidget *parent)
    2. : QDialog(parent)
    3. {
    4. this->setMinimumSize(800, 250);
    5. QTimer::singleShot(5000, this, SLOT(updateGraph()));
    6. }
    7.  
    8. Dialog::~Dialog()
    9. {
    10. }
    11.  
    12.  
    13. void Dialog::paintEvent(QPaintEvent *event)
    14. {
    15. Q_UNUSED(event);
    16. QPainter painter(this);
    17. addGraphs(&painter, 20, 30, 50);
    18. }
    19.  
    20. void Dialog::addGraphs(QPainter *qp, int i, int j, int k)
    21. {
    22. Nightcharts chart1;
    23. chart1.setShadows(false);
    24. chart1.setType(Nightcharts::Pie);
    25. chart1.setLegendType(Nightcharts::Vertical);
    26. chart1.setCords(50, 50, 80, 80);
    27. chart1.addPiece("Item1",QColor(200,10,50), i);
    28. chart1.addPiece("Item2",Qt::green, j);
    29. chart1.addPiece("Item3",Qt::cyan, k);
    30. chart1.draw(qp);
    31. chart1.drawLegend(qp);
    32.  
    33. Nightcharts chart2;
    34. chart2.setShadows(false);
    35. chart2.setType(Nightcharts::Pie);
    36. chart2.setLegendType(Nightcharts::Vertical);
    37. chart2.setCords(300, 50, 80, 80);
    38. chart2.addPiece("Item2",Qt::green, j);
    39. chart2.addPiece("Item3",Qt::cyan,k);
    40. chart2.addPiece("Item4",Qt::yellow,i);
    41. chart2.draw(qp);
    42. chart2.drawLegend(qp);
    43.  
    44. Nightcharts chart3;
    45. chart3.setShadows(false);
    46. chart3.setType(Nightcharts::Pie);
    47. chart3.setLegendType(Nightcharts::Vertical);
    48. chart3.setCords(550, 50, 80, 80);
    49. chart3.addPiece("Item1",QColor(200,10,50), k);
    50. chart3.addPiece("Item3",Qt::cyan, i);
    51. chart3.addPiece("Item4",Qt::yellow, j);
    52. chart3.draw(qp);
    53. chart3.drawLegend(qp);
    54. }
    55.  
    56. void Dialog::updateGraph()
    57. {
    58. qDebug("Updating after 5 seconds");
    59. QPainter painter(this);
    60. addGraphs(&painter, 50, 20, 30);
    61. this->update();
    62. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by rawfool; 23rd April 2013 at 14:01.

Similar Threads

  1. QComboBox refresh problem
    By waynew in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2011, 12:30
  2. Replies: 2
    Last Post: 14th January 2011, 15:09
  3. QWidget Refresh Problem
    By MarkoSan in forum Qt Programming
    Replies: 2
    Last Post: 15th January 2008, 11:24
  4. QpaintEvent region problem with QPopupmenus
    By Qtkiller in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2007, 09:18
  5. QTableView refresh problem
    By tebessum in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2006, 11:22

Tags for this Thread

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.