PDA

View Full Version : QPixmap Crash - "...terminate it in an unusual way" (QT4.4)



QT8seven
4th December 2011, 05:21
I have done the following:

Created a new empty QT project.
Added a source file.



#include <QPixmap>

int main(int argC,char** argV)
{
QPixmap("D:\new.png");
}


This results in:


This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

I am hoping someone can help me figure out how to resolve this issue. I have had it on a much larger scale and been able to work out that the error occurs with even the smallest of scales, as seen above. What would cause such a crash when using QPixmap?

Lykurg
4th December 2011, 07:37
Hi,

you can use a QPixmap only inside the GUI thread thus you have to initialize QApplication first. Or use QImage instead, which don't need a GUI thread.

QT8seven
4th December 2011, 13:56
Perfect, thank you.

ChrisW67
4th December 2011, 22:29
Once you have a QApplication instance you need to either double the backslash in the path to your file, i.e. "D:\\new.png", or use forward slashes and let Qt work it out for you.