• 2477阅读
  • 0回复

求助 [复制链接]

上一主题 下一主题
离线iaccepted
 

只看楼主 倒序阅读 楼主  发表于: 2014-04-18
继承QWidget;实现了一个类
  1. class Paint : public QWidget
  2. {
  3.   Q_OBJECT
  4. public:
  5.   explicit Paint(QWidget *parent = 0);
  6.   void write(QPainter *p);
  7. protected:
  8.   void paintEvent(QPaintEvent *);
  9. signals:
  10. public slots:
  11. };
  12. void Paint::paintEvent(QPaintEvent *)
  13. {
  14.   QPainter p(this);
  15.   p.setPen(QColor(0,0,0));
  16.   QPixmap pixmap;
  17.   pixmap.load(":/image/1.png");
  18.   p.drawPixmap(30,30,40,40,pixmap);
  19.   qDebug()<<3;
  20. }
  21. MainWindow::MainWindow(QWidget *parent) :
  22.   QMainWindow(parent),
  23.   ui(new Ui::MainWindow)
  24. {
  25.   ui->setupUi(this);
  26.   p = new Paint(this);
  27.   p->show();//调用后为什么没画出来呢??
  28. }
菜鸟一枚,求大家帮忙解释下。
在技术的道路上我一直在追求卓越……
快速回复
限100 字节
 
上一个 下一个