首页 文章

std :: ANYTHING未声明

提问于
浏览
0

解决方案我基于答案尝试

  • 刚删除'using namespace std;'行并没有用 .

  • 我在'#include '之前和之后放了那条线,既没有奏效 .

谢谢Yksisarvinen

  • 删除了QT默认应用程序以外的所有文件(当然还有图像)

  • 尝试了这个,但得到了同样的错误

//#include "mainwindow.h"
//#include <QApplication>

#include <QtCore>
int main() { qDebug() << "Hello, world!"; }

/*
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}
*/

谢谢Kuba Ober

  • 在.pro文件中添加了以下行 . 该解决方案适用于使用QT进行编译
INCLUDEPATH +=/usr/include

但我仍然无法使用终端编译(这是我的历史的一部分)

cat main.cpp
g++ main.cpp
echo $LD_LIBRARY_PATH
g++ main.cpp
LD_LIBRARY_PATH='' g++ main.cpp
export LD_LIBRARY_PATH=''
echo $LD_LIBRARY_PATH
g++ main.cpp
ls /usr/include/c++/7/
echo $CXX
echo $CC
echo $CC=clang
export CC=clang
export CXX=clang++
echo $CC=clang
echo $CC
g++ main.cpp
echo $INCLUDEPATH
export INCLUDEPATH = /usr/include
export INCLUDEPATH=/usr/include
echo $INCLUDEPATH
ls
g++ main.cpp
echo $INCLUDEPATH
history

我现在可以工作了(可能我会在度假时格式化ubuntu),但我不想将其标记为已解决,因为仍然有些东西没有正常工作 .

谢谢Marcelo Cardenas(大学的朋友)

  • 无论如何,感谢您的提示,希望我们能解决这个问题:)

我有这个QT应用程序:https://drive.google.com/file/d/15d4mYLgJcKOB5tpEwfuFBPXETUbR8CFK/view?usp=sharing

曾经工作过 . 现在我得到this . 500错误的假定未定义的功能 .

我不知道在哪里找错误 .

我目前正在与:

  • 操作系统:Ubuntu 18.04.1 LTS

  • 内核:4.16.0-041600-通用

  • Cuda: Build 于Tue_Jun_12_23:07:04_CDT_2018 Cuda编译工具,
    版本9.2,V9.2.148

  • gcc :( Ubuntu 7.3.0-27ubuntu1~18.04)7.3.0

  • QMake:版本3.1

  • Qt版本:5.9.6

  • OpenGL版本:3.0 Mesa 18.0.5

  • OpenCV版本:4.0.0(通过命令cat /home/pablo/OpenCV-3.0.0/OpenCV-3.0.0-master/opencv/build/OpenCVConfig.cmake获得)

这是.pro文件:

#-------------------------------------------------
#
# Project created by QtCreator 2018-10-31T18:03:31
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Ayudantia2
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as 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 you use 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

CONFIG += c++11

SOURCES += \
        main.cpp \
        mainwindow.cpp

HEADERS += \
        mainwindow.h

FORMS += \
        mainwindow.ui

和 Headers

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <ui_mainwindow.h>
#include <set>
//#include <mainwindow.h>
#include <QMainWindow>

#include <QFileDialog>  //para buscar archivos por ventana
#include <QMessageBox>  //para mensajes del sistema
#include <QImage>       //para manipular imagenes basicamente(mas fome que opencv)

#include <cstdlib>

using namespace std;

#include <iostream>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

    public:
        explicit MainWindow(QWidget *parent = nullptr);
        ~MainWindow();


    public slots:
        void cargarTexto(QString);
        void cargarImagen(int area);
        void buscarImagen1();
        void buscarImagen2();
        void buscarImagen3();
        void mostrarImagen4();
        void mostrarImagen5();
        void mostrarImagen6();
        void filtrarImagen();
        void ponderar();
        void colorPlano();

    signals:
        void textoListo(QString);
        int imagenLista(int);
        int filtrar1(int);
        int filtrar2(int);
        int filtrar3(int);
        int valueChanged();
        void cambiocolor();
        QString ruta1(QString);
        QString ruta2(QString);
        QString ruta3(QString);

    private slots:

    private:
        Ui::MainWindow *ui;
        QImage imagenes[8];
};

#endif // MAINWINDOW_H

这个id是主窗口

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget* parent):
    QMainWindow(parent),
    ui(new Ui::MainWindow){
        ui->setupUi(this);

        QObject::connect(ui->actionCargar_imagen_1, SIGNAL(triggered()),this, SLOT(buscarImagen1()));
        QObject::connect(ui->actionCargar_imagen_2, SIGNAL(triggered()),this, SLOT(buscarImagen2()));
        QObject::connect(ui->actionCargar_imagen_3, SIGNAL(triggered()),this, SLOT(buscarImagen3()));

        QObject::connect(ui->Fusion, SIGNAL(valueChanged(int)),this, SLOT(ponderar()));

        QObject::connect(this, SIGNAL(filtrar1(int)),this, SLOT(mostrarImagen4()));
        QObject::connect(this, SIGNAL(filtrar2(int)),this, SLOT(mostrarImagen5()));
        QObject::connect(this, SIGNAL(filtrar3(int)),this, SLOT(mostrarImagen6()));

        QObject::connect(this, SIGNAL(imagenLista(int)),this, SLOT(cargarImagen(int)));

        QObject::connect(ui->btn_Filtrar, SIGNAL(released()),this, SLOT(filtrarImagen()));

        QObject::connect(ui->RedSlider, SIGNAL(valueChanged(int)),this,SLOT(colorPlano()));
        QObject::connect(ui->BlueSlider, SIGNAL(valueChanged(int)),this,SLOT(colorPlano()));
        QObject::connect(ui->GreenSlider, SIGNAL(valueChanged(int)),this,SLOT(colorPlano()));

        QObject::connect(this, SIGNAL(cambiocolor()),this, SLOT(mostrarImagen7()));

        QImage imagenes[8];
        for(int i=0;i<8;i++){
            imagenes[i]=QImage();
        }
}

////////////////////////////////////////////////////////////////


void MainWindow::buscarImagen1(){
    QString fileName = QFileDialog::getOpenFileName(this, tr("Abrir Imagen"), "./", tr("Imagen (*.png *.jpg *.jpeg *.bmp *.ppm);; All files (*.*)"));
    if(fileName == "") return;
    //emit ruta1(fileName);
    emit textoListo(fileName);
    imagenes[0] = QImage(fileName);
    imagenes[0]= imagenes[0].scaled(170,170);
    if(imagenes[0].isNull()){
        QMessageBox::information(this, tr("Error de carga!!"),tr("No se puede cargar %1. ").arg(fileName));
        imagenes[0] = QImage();
        return;
    }
    ui->Ruta1->setText(fileName);
    emit imagenLista(0);
}

void MainWindow::buscarImagen2(){
    QString fileName = QFileDialog::getOpenFileName(this, tr("Abrir Imagen"), "./", tr("Imagen (*.png *.jpg *.jpeg *.bmp *.ppm);; All files (*.*)"));
    if(fileName == "") return;
    //emit ruta2(fileName);
    emit textoListo(fileName);
    imagenes[1] = QImage(fileName);
    imagenes[1]= imagenes[1].scaled(170,170);
    if(imagenes[1].isNull()){
        QMessageBox::information(this, tr("Error de carga!!"),tr("No se puede cargar %1. ").arg(fileName));
        imagenes[1] = QImage();
        return;
    }
    ui->Ruta2->setText(fileName);
    emit imagenLista(1);
}

void MainWindow::buscarImagen3(){
    QString fileName = QFileDialog::getOpenFileName(this, tr("Abrir Imagen"), "./", tr("Imagen (*.png *.jpg *.jpeg *.bmp *.ppm);; All files (*.*)"));
    if(fileName == "") return;
    //emit ruta3(fileName);
    emit textoListo(fileName);
    imagenes[2] = QImage(fileName);
    imagenes[2]= imagenes[2].scaled(170,170);
    if(imagenes[2].isNull()){
        QMessageBox::information(this, tr("Error de carga!!"),tr("No se puede cargar %1. ").arg(fileName));
        imagenes[2] = QImage();
        return;
    }
    ui->Ruta3->setText(fileName);
    emit imagenLista(2);
}
///////////////////////////////////////////////////////////////
void MainWindow::mostrarImagen4(){
    emit imagenLista(4);
}

void MainWindow::mostrarImagen5(){
    emit imagenLista(5);
}

void MainWindow::mostrarImagen6(){
    emit imagenLista(6);
}
///////////////////////////////////////////////////////////////scrollArea_1
void MainWindow::cargarTexto(QString texto){
        ui->Ruta1->setText(texto);
}

///////////////////////////
void MainWindow::cargarImagen(int area) {
    QImage *out = new QImage(imagenes[area]);
    QLabel *label = new QLabel;
    label->setPixmap(QPixmap::fromImage(*out, Qt::AutoColor));

    if (area == 0) ui->scrollArea_1->setWidget(label);
    if (area == 1) ui->scrollArea_2->setWidget(label);
    if (area == 2) ui->scrollArea_3->setWidget(label);
    if (area == 3) ui->scrollArea_4->setWidget(label);
    if (area == 4) ui->scrollArea_5->setWidget(label);
    if (area == 5) ui->scrollArea_6->setWidget(label);
    if (area == 6) ui->scrollArea_7->setWidget(label);
    if (area == 7) ui->scrollArea_8->setWidget(label);
}

//////////////////////////////////////////////////////////////
void MainWindow::filtrarImagen(){
    int R,G,B;
    QColor pixelRGB;
    imagenes[4]=imagenes[0];
    if(imagenes[4].isNull()) imagenes[4] = QImage();
    imagenes[5]=imagenes[1];
    if(imagenes[5].isNull()) imagenes[5] = QImage();
    imagenes[6]=imagenes[2];
    if(imagenes[6].isNull()) imagenes[6] = QImage();

    for(int k=0;k<3;k++){
        if (imagenes[k].isNull()) continue;
        for(int i=0;i<imagenes[k].height();i++){
            for(int j=0;j<imagenes[k].width();j++){
                pixelRGB=imagenes[k].pixelColor(i,j);
                R = pixelRGB.red();
                G = pixelRGB.green();
                B = pixelRGB.blue();
                if(ui->Tresched_chBox->isChecked()){
                    if(R < ui->RedSlider->value()){
                        R=0;
                    }
                    if(G < ui->GreenSlider->value()){
                        G=0;
                    }
                    if(B < ui->BlueSlider->value()){
                        B=0;
                    }
                }
                if(ui->Tresched_chBox->isChecked()==false){
                    if(R > ui->RedSlider->value()){
                        R=0;
                    }
                    if(G > ui->GreenSlider->value()){
                        G=0;
                    }
                    if(B > ui->BlueSlider->value()){
                        B=0;
                    }
                }
                //printf("(%i,%i,%i)",R,G,B);
                imagenes[k+4].setPixelColor(i,j,QColor(R,G,B,0));
            }
        }
    }
    emit filtrar1(4);
    emit filtrar2(5);
    emit filtrar3(6);
}

//////////////////////////////////////////////////////////////
void MainWindow::ponderar(){
    if((imagenes[1].isNull() == false) and (imagenes[2].isNull() == false)){
        imagenes[3] = imagenes[2];
        float ponderacion = (float) ui->Fusion->value();
        QColor pixelRGB1,pixelRGB2;
        int R1,G1,B1,R2,G2,B2,R3,G3,B3;
        int alfa1,alfa2,alfa3;
        for(int i=0;i<imagenes[1].height();i++){
            for(int j=0;j<imagenes[1].width();j++){
                pixelRGB1=imagenes[1].pixelColor(i,j);
                R1 = pixelRGB1.red();
                G1 = pixelRGB1.green();
                B1 = pixelRGB1.blue();
                alfa1 = pixelRGB1.alpha();
                pixelRGB2=imagenes[2].pixelColor(i,j);
                R2 = pixelRGB2.red();
                G2 = pixelRGB2.green();
                B2 = pixelRGB2.blue();
                alfa2 = pixelRGB2.alpha();
                R3=(R1*ponderacion/100.0 + R2*(100.0-ponderacion)/100.0);
                G3=(G1*ponderacion/100.0 + G2*(100.0-ponderacion)/100.0);
                B3=(B1*ponderacion/100.0 + B2*(100.0-ponderacion)/100.0);
                alfa3=(alfa1*ponderacion/100.0 + alfa2*(100.0-ponderacion)/100.0);
                //printf("(%i,%i,%i)",R3,G3,B3);
                imagenes[3].setPixelColor(i,j,QColor(R3,G3,B3,alfa3));
            }
        }
    emit imagenLista(3);
    }
}
//////////////////////////////////////////////////////////////
void MainWindow::colorPlano(){
        imagenes[7] = QImage(175,175,QImage::Format_RGB32);
        int R,G,B;
        R = ui->RedSlider->value();
        G = ui->GreenSlider->value();
        B = ui->BlueSlider->value();
        for(int i=0;i<imagenes[7].height();i++){
            for(int j=0;j<imagenes[7].width();j++){
                imagenes[7].setPixelColor(i,j,QColor(R,G,B));
            }
        }
        emit cambiocolor();
        emit imagenLista(7);
}
//////////////////////////////////////////////////////////////
MainWindow::~MainWindow(){
    delete ui;
}
/////////////////////////////////////////////

其余代码位于此问题顶部的链接上 . 感谢您帮助我,我是ubuntu,qt和c的新手,我想改进,当每个解决方案都产生另一个错误时,它非常令人沮丧 .

1 回答

  • 0

    您的源文件夹似乎包含来自其他系统的过时构建产品 . 现代Qt Creator永远不会将这些输出文件放在源文件夹中 . 关闭Qt Creator,然后删除除下面以外的所有文件:

    • Ayudantia2.pro

    • main.cpp

    • mainwindow.cpp

    • mainwindow.h

    • mainwindow.ui

    • marge.jpeg

    • pdi.jpeg

    上面的文件必须是源文件夹中保留的 only 文件 . 确保你不会错过隐藏的文件,特别是删除:

    • .qmake.stash remove

    然后打开Qt Creator,打开项目,为当前的Qt版本配置它,然后再次尝试构建 .

相关问题