-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
46 lines (39 loc) · 1.11 KB
/
mainwindow.cpp
File metadata and controls
46 lines (39 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPainter>
#include <QDebug>
#include<iostream>
#include<QFile>
#include<QFileDialog>
using namespace std;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QString file= QFileDialog::getOpenFileName(this,QString("选择第一幅图片"),QString("/"),QString("*"));
QImage img(file);
if(img.isNull())
{
fprintf(stderr,"Can not load image %s\n",file);
}
ui->label_12->setScaledContents(true);
QSize qs=ui->label_12->rect().size();
ui->label_12->setPixmap(QPixmap::fromImage(img).scaled(qs));
QString file2= QFileDialog::getOpenFileName(this,QString("选择第二幅图片"),QString("/"),QString("*"));
QImage img2(file2);
if(img.isNull())
{
fprintf(stderr,"Can not load image %s\n",file);
}
ui->label_13->setScaledContents(true);
QSize qs2 = ui->label_13->rect().size();
ui->label_13->setPixmap(QPixmap::fromImage(img2).scaled(qs2));
}