QPicturePaintEngine::checkFormat: Incorrect header

  • I'm attempting to load a QPicture so I can use it to draw on a printer using a QPainter.

    I'm using a QPicture because the printing documentation says that the QPicture info,size,etc. will not be changed or adjusted by the QPainter which might be at a different DPI than the physical print device.

    I need the printed output to be in an exact dimension...if the image being sent to a 600dpi printer via the painter is 600x600pixels then I need it to be printed at 2.54mmx2.54mm.

    Can't figure out why the QPicture is complaining about the file header. The file is a .png format in the code below, but I've also tried .jpg, .bmp, .tif., .gif with the same result. Using the Windows Photo View or the Windows Paint program then .png file can be displayed without any problem.

    The code is something like this...

    QPrinter *printer = new QPrinter;

    QPrintDialog *printDialog = new QPrintDialog(printer, this);
    if (printDialog->exec() == QDialog::Accepted)
    QPainter p(printer);

    // load picture
    QPicture pic;
    #if DEBUG_Ruler
    qDebug() << "-on_pbMakeRuler: pic format scaled png=" &lt;&lt; pic.pictureFormat(filePath + "tmpRulerScaled.png");
    qDebug() << "-on_pbMakeRuler: pic format png=" &lt;&lt; pic.pictureFormat(filePath +  "tmpRuler.png");
    qDebug() << "-on_pbMakeRuler: pic format gif=" &lt;&lt; pic.pictureFormat(filePath +  "tmpRuler.gif");
    qDebug() << "-on_pbMakeRuler: pic format tif=" &lt;&lt; pic.pictureFormat(filePath +  "tmpRuler.tif");

    debug output=-on_pbMakeRuler: pic format scaled png=
    debug output=-on_pbMakeRuler: pic format png=
    debug output=-on_pbMakeRuler: pic format gif=
    debug output=-on_pbMakeRuler: pic format tif=

    //QStringList list = QPicture::inputFormatList();
    QStringList list = pic.inputFormatList();
    foreach (const QString &string, list)
      qDebug() << "-pic format=" &lt;&lt; string;

    >>debug output= nothing

    bool found = QFile::exists( filePath +  "tmpRulerScaled.png" );
    #if DEBUG_Ruler
    qDebug() << "-on_pbMakeRuler: pic findFile=" &lt;&lt; found;

    >>debug output= -on_pbMakeRuler: pic findFile= true

    pic.load(filePath +  "tmpRulerScaled.png");

    Qt output in the application output window= QPicturePaintEngine::checkFormat: Incorrect header
    p.drawPicture(100, 0, pic);


    I'm at a loss. Any help would be appreciated.

  • check if you have the necessary Qt images plugins installaed, on ubuntu the folder is: /usr/lib/qt4/plugins/imageformats/

    you will find:


  • I'll assume that the ".so" extension is a ubuntu thing.

    I do have a directory ..Qt\mingw\plugins\imageformats\ that contains those "libq" files with both .a and .dll extensions.

    Does the QPicture load method only accept files with a .pic extension? That's the only extension referenced in the online docs..at least that I've been able to find.

    It there a way to load a QPicture indirectly from a QPixmap with something like..

    @QPixmap pm = QPixmap::grabWidget(ui->lblQImageScaled); //from a QLabel pixmap@

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.