Home > Mobile >  QT opencv configuration error display images
QT opencv configuration error display images

Time:09-18

Bosses, I novice, recent call with QT opencv display pictures, program is easy, but have not learned QT, encountered an error, setPixmat this function error, I see the video code is written in the automatic color change, I don't change color, and the error is said here, this is a video link https://edu.51cto.com/course/12055.html? Source=so my feeling is that the reason why I copy and paste, something didn't change, don't know what's bosses opinion, can leave a message oh,
Post some pictures, code below,

Pro file:
 
QT +=core GUI

GreaterThan (QT_MAJOR_VERSION, 4) : QT +=widgets

TARGET=20200223
The TEMPLATE=app


DEFINES +=QT_DEPRECATED_WARNINGS


INCLUDEPATH +=E:/opencv - 3.2.0/newbuild/install/include \
E:/opencv - 3.2.0/newbuild/install/include/opencv \
E:/opencv - 3.2.0/newbuild/install/include/opencv2

LIBS +=E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_core320. DLL. A \
E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_highgui320. DLL. A \
E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_imgproc320. DLL. A \
E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_imgcodecs320. DLL. A \
E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_highgui320. DLL. A \
E:/opencv - 3.2.0/newbuild/install/x86/mingw/lib/libopencv_videoio320. DLL. A

SOURCES +=\
The main. CPP \
Mainwindow. CPP

HEADERS +=\
Mainwindow. H

FORMS +=\
Mainwindow. UI



Mainwindow. H
 # # ifndef MAINWINDOW_H 
# define MAINWINDOW_H

# include & lt; QMainWindow>

The namespace Ui {
The class MainWindow.
}

The class MainWindow: public QMainWindow
{
Q_OBJECT

Public:
Explicit MainWindow (QWidget * parent=0);
~ MainWindow ();

Private slots:
Void on_pushButton_clicked ();

Private:
Ui: : MainWindow * Ui;
};

# endif//MAINWINDOW_H


The main
 # include "mainwindow. H" 
# include & lt; QApplication>

Int main (int arg c, char * argv [])
{
QApplication a (arg c, argv);
The MainWindow w;
Baron how ();

Return a.e xec ();

}


Mainwindow. CPP
 # include "mainwindow. H" 
# include "ui_mainwindow. H"
#include
#include
#include
#include
Using the namespace CV;

MainWindow: : MainWindow (QWidget * parent) :
QMainWindow (parent),
UI (new UI: : MainWindow)
{
The UI - & gt; SetupUi (this);
}

MainWindow: : ~ MainWindow ()
{
Delete the UI;
}



Void MainWindow: : on_pushButton_clicked ()
{
QString img_name=QFileDialog: : getOpenFileName (this, tr (" Open Image "), ". ", the tr (" Image Files (*. PNG *. JPG *. Jpeg *. BMP) "));
Mat src=https://bbs.csdn.net/topics/imread (img_name toLatin1 (). The data ());
CV: : cvtColor (SRC, SRC, CV_BGR2RGB);
QImage img=QImage ((const unsigned char *) (SRC) data), SRC, cols, SRC, rows, QImage: : Format_RGB888);
The UI - & gt; PushButton - & gt; SetPixmap (QPixmap: : fromImage (img));
}

CodePudding user response:

SetPixmap is a function of QLabel
You have to learn to check document
SetIcon function button

CodePudding user response:

Qt provides an introduction to the three pictures of class, to learn how to use the help documentation, to check you need class: QImage, QPixmap, QBitmap, QPicture.

CodePudding user response:

The meaning of this sentence is QPushButton setPixmap members of the class does not function
  •  Tags:  
  • Qt
  • Related