fork download
  1. #include "widget.h"
  2. #include <QPainter>
  3. #include <cmath>
  4.  
  5. Widget::Widget(QWidget *parent)
  6. : QWidget(parent)
  7. {
  8. startTimer(40);
  9. }
  10.  
  11. Widget::~Widget()
  12. {
  13.  
  14. }
  15. void Widget::paintEvent(QPaintEvent *event)
  16. {
  17. QPainter p(this);
  18. p.setRenderHint(QPainter::Antialiasing);
  19. double w, h, left, top;
  20. const auto p=4./3;
  21. if (width() < r*height()){
  22. //b
  23. w = width();
  24. h = w/r;
  25. left = 0;
  26. top = (height() - h)/2
  27. }
  28. else{
  29. //a
  30. h = hight();
  31. w = h*r;
  32. left = (width() - w)/2
  33. top = 0;
  34. }
  35. auto blackRadius = 0.1*h+m_time*100;
  36. if (blackRadius <h)
  37. {
  38. p.setPen(Qt::NoPen);
  39. p.setBrush(Qt::black);
  40. QPointF blackCenter (left+0.5*w, top+0.5*h);
  41. p.drawEllipse(blackCenter, blackRadius, blackRadius);
  42. }
  43. else {
  44. auto darkGrayRadius = 0.1*h+m_time*100;
  45. p.setPen(Qt::NoPen);
  46. p.setBrush(Qt::darkGray);
  47. QPointF darkGrayCenter (left+0.5*w, top+0.5*h);
  48. p.drawEllipse(darkGrayCenter, darkGrayRadius, darkGrayRadius);
  49. }
  50. }
  51.  
  52. void Widget::timerEvent(QTimerEvent *)
  53. {
  54. autodt=40/1000.;
  55. m_time +=dt;
  56. update();
  57. }
  58.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:20: fatal error: widget.h: No such file or directory
 #include "widget.h"
                    ^
compilation terminated.
stdout
Standard output is empty