Your code compiles just fine here (it may not do what you expect but that's another problem). What is your actual error message and/or your actual code?
#include <QApplication>
#include <QImage>
int main(int argc, char **argv)
{
const int DEFAULT_IMAGE_WIDTH = 320;
const int DEFAULT_IMAGE_HEIGHT = 480;
unsigned char m_raw_data[DEFAULT_IMAGE_WIDTH * DEFAULT_IMAGE_HEIGHT];
// YOUR CODE
QVector<QRgb> colorTable;
for(int i = 0; i < 256; i++){
colorTable.append(qRgb(i,i,i));
}
memset(m_raw_data, 0, DEFAULT_IMAGE_WIDTH*DEFAULT_IMAGE_HEIGHT);
m_image
= new QImage(m_raw_data, DEFAULT_IMAGE_WIDTH,DEFAULT_IMAGE_HEIGHT,
QImage::Format_Indexed8);
m_image->setColorTable(colorTable);
// END YOUR CODE
delete m_image;
return 0;
}
#include <QApplication>
#include <QImage>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
const int DEFAULT_IMAGE_WIDTH = 320;
const int DEFAULT_IMAGE_HEIGHT = 480;
unsigned char m_raw_data[DEFAULT_IMAGE_WIDTH * DEFAULT_IMAGE_HEIGHT];
QImage *m_image;
// YOUR CODE
QVector<QRgb> colorTable;
for(int i = 0; i < 256; i++){
colorTable.append(qRgb(i,i,i));
}
memset(m_raw_data, 0, DEFAULT_IMAGE_WIDTH*DEFAULT_IMAGE_HEIGHT);
m_image = new QImage(m_raw_data, DEFAULT_IMAGE_WIDTH,DEFAULT_IMAGE_HEIGHT,QImage::Format_Indexed8);
m_image->setColorTable(colorTable);
// END YOUR CODE
delete m_image;
return 0;
}
To copy to clipboard, switch view to plain text mode
$ ~/Qt5.1.1/5.1.1/gcc_64/bin/qmake
$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/home/chrisw/Qt5.1.1/5.1.1/gcc_64/mkspecs/linux-g++ -I. -I. -I/home/chrisw/Qt5.1.1/5.1.1/gcc_64/include -I/home/chrisw/Qt5.1.1/5.1.1/gcc_64/include/QtWidgets -I/home/chrisw/Qt5.1.1/5.1.1/gcc_64/include/QtGui -I/home/chrisw/Qt5.1.1/5.1.1/gcc_64/include/QtCore -I. -o main.o main.cpp
g++ -Wl,-O1 -Wl,-rpath,/home/chrisw/Qt5.1.1/5.1.1/gcc_64 -Wl,-rpath,/home/chrisw/Qt5.1.1/5.1.1/gcc_64/lib -o tt main.o -L/home/chrisw/Qt5.1.1/5.1.1/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
$
$ ~/Qt5.1.1/5.1.1/gcc_64/bin/qmake
$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/home/chrisw/Qt5.1.1/5.1.1/gcc_64/mkspecs/linux-g++ -I. -I. -I/home/chrisw/Qt5.1.1/5.1.1/gcc_64/include -I/home/chrisw/Qt5.1.1/5.1.1/gcc_64/include/QtWidgets -I/home/chrisw/Qt5.1.1/5.1.1/gcc_64/include/QtGui -I/home/chrisw/Qt5.1.1/5.1.1/gcc_64/include/QtCore -I. -o main.o main.cpp
g++ -Wl,-O1 -Wl,-rpath,/home/chrisw/Qt5.1.1/5.1.1/gcc_64 -Wl,-rpath,/home/chrisw/Qt5.1.1/5.1.1/gcc_64/lib -o tt main.o -L/home/chrisw/Qt5.1.1/5.1.1/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
$
To copy to clipboard, switch view to plain text mode
Bookmarks