MrcFreeman 2021-07-24 16:04 采纳率: 0%
浏览 26
已结题

为什么会出现重复定义的报错?

这里为什么会出现重复定义的报错。我的.pro文件里没有重复出现的文件,但是个人认为代码不存在问题,urgent mission!thanks!

widget.cpp

#include "widget.h"
#include "ui_widget.h"
#include <QFileDialog>
#include <QMessageBox>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    connect(ui->pushButton_1,SIGNAL(clicked),ui->label_1,SLOT(checkpic1()));
    connect(ui->pushButton_2,SIGNAL(clicked),ui->label_2,SLOT(checkpic1()));
}

Widget::~Widget()
{
    delete ui;
}

QString Widget:: checkpic1()
{
    QString pic1;
    pic1=QFileDialog::getOpenFileName(this,
                                        tr("选择图像"),
                                        "",
                                        tr("Images (*.png *.bmp *.jpg *.tif *.GIF )"));//可打开的文件类型
    if(!pic1.isEmpty())
    {
        QImage* img=new QImage;
        if(! ( img->load(pic1) ) ) //加载图像
            {
                QMessageBox::information(this,
                                         tr("打开图像失败"),
                                         tr("打开图像失败!"));
                delete img;
            }
        ui->label->setPixmap(QPixmap::fromImage(*img));
    }
    return pic1;
}

QString Widget::checkpic2()
{
    QString pic2;
    pic2=QFileDialog::getOpenFileName(this,
                                        tr("选择图像"),
                                        "",
                                        tr("Images (*.png *.bmp *.jpg *.tif *.GIF )"));//可打开的文件类型
    if(!pic2.isEmpty())
    {
        QImage* img=new QImage;
        if(! ( img->load(pic2) ) ) //加载图像
            {
                QMessageBox::information(this,
                                         tr("打开图像失败"),
                                         tr("打开图像失败!"));
                delete img;
            }
        ui->label->setPixmap(QPixmap::fromImage(*img));
    }
    return pic2;
}

.pro

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    widget.cpp

HEADERS += \
    widget.h

FORMS += \
    widget.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target


img

img

  • 写回答

1条回答 默认 最新

  • 有问必答小助手 2021-07-26 18:56
    关注

    你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答

    本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。

    ​​​​因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。

    评论

报告相同问题?

问题事件

  • 系统已结题 8月1日
  • 创建了问题 7月24日

悬赏问题

  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能