Qt for Symbian 加载图片


Qt for Symbian 加载图片

#include <QApplication>

#include <QWidget>
#include <QPainter>
#include <QBitmap>
class PainterWidget : public QWidget {
protected:
 void paintEvent(QPaintEvent*);
};s
void PainterWidget::paintEvent(QPaintEvent *event) {
 /*Qt 4.7.3 reference document:
 QPixmap::QPixmap ( const QString & fileName, const char * format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor )
 
 The fileName, format and flags parameters are passed on to load().
 This means that the data in fileName is not compiled into the binary.
 If fileName contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.
 */
 //在手机上这个路径个人倾向设成绝对路径。www.bkjia.com设成相对路径的话这个文件大多通过资源文件加载方式完成的,不灵活
 QPixmap pixImg("E:/localImage.png");
  QPainter painter(this);
 painter.drawPixmap(0, 0, pixImg);
}
int main(int argc, char *argv[]) {
 QApplication app(argc, argv);
 PainterWidget pWidget;
 pWidget.setWindowTitle("QPixmap & QBitmap");
 //适配nokia 5530!
 pWidget.setGeometry(0,0,360,640);
 pWidget.showFullScreen();
 return app.exec();
}

相关内容