Newbie problem with QT C++ - Qimage dont work?

11,495

It is possible to use QImage in a console application, you must make sure that QtGui is configured though. If you chose a console app, your .pro file might contain something like

CONFIG += console
QT -= gui

If that's the case, remove the QT -= gui line.

Share:
11,495
John X
Author by

John X

Updated on August 20, 2022

Comments

  • John X
    John X over 1 year

    I am trying to do console application to read pixels from image:

    #include <QtCore/QCoreApplication>
    #include <QtGui/QImage>
    
    #include <iostream>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
        QImage *img = new QImage("adadad.jpg");
    
        //std::cout << "Type filename:" << std::endl;
        img->isNull();
        return a.exec();
    }
    

    That doesn't work I got: (IT doesn't compile, but anyway file isn't exist yet...)

    File not found: tmp/obj/debug_shared/main.o:: In function `main':
    

    What is going on? Is it impossible to use Qimage with console app?!

    EDIT: screen