// MainScens.h
#ifndef MAINSCENS_H
#define MAINSCENS_H
#include <QMainWindow>
namespace Ui {
class MainScens;
}
class MainScens : public QMainWindow
{
Q_OBJECT
public:
explicit MainScens(QWidget *parent = 0);
void paintEvent(QPaintEvent *);
~MainScens();
private:
Ui::MainScens *ui;
};
#endif // MAINSCENS_H
//MainScens.cpp
#include "MainScens.h"
#include "ui_MainScens.h"
#include <QPushButton>
#include <QPainter>
MainScens::MainScens(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainScens)
{
ui->setupUi(this);
// 设置固定大小
this->setFixedSize(600, 400);
// 设置窗口图标
this->setWindowIcon(QIcon(":/Image/xxy.png"));
// 设置窗口标题
this->setWindowTitle("main window");
connect(this->ui->actionquit, QAction::triggered, this, QWidget::close);
}
void MainScens::paintEvent(QPaintEvent *) {
QPainter painter(this);
QPixmap pix;
pix.load(":/Image/scjc.png");
painter.drawPixmap(0, 0, this->width(), this->height(), pix);
}
MainScens::~MainScens()
{
delete ui;
}
量化交易之QT篇 - 设置窗口大小、标题、icon(画背景图片)
最新推荐文章于 2024-03-05 16:30:52 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)