标签:qt
选择application模板,一路确定
创建完目录如下
修改mainwindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); protected: void paintEvent(QPaintEvent *); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
修改mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QPainter> #include <QRectF> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::paintEvent(QPaintEvent *){ QPainter p(this); p.drawText(QRectF(30,30,100,100),QString("Hellow Word!")); }
标签:qt
原文地址:http://nanguazhude.blog.51cto.com/2344154/1613813