[Qt-interest] Repainting a QFrame with a image.

Chris W01 lordchrisw01 at yahoo.com
Tue Nov 3 04:15:09 CET 2009


Hello everyone, I was wondering if someone could help me. I am designing a QT App that is skinable however when I try to replace the background on the QFrame with a image it fails to update the frame. 

Here is some test code.

My header file.



p, li { white-space: pre-wrap; }

#ifndef JAPGTESTFRAME_H
#define JAPGTESTFRAME_H
#include <QFrame>


class japgTestFrame : public QFrame
{
public:
    japgTestFrame(const char * name, QWidget *parent = 0);
};

#endif // JAPGTESTFRAME_H
My C_++ file.  pre-wrap; }


#include "japgtestframe.h"
#include <QDebug>


#include <QImage>#include <QPainter>japgTestFrame::japgTestFrame(const char * name, QWidget *parent) : QFrame(parent)
{
    QPalette japgPalette;
    QString string(name);
    QFrame frame(parent);

    if(string.compare(QString("main")) == 0) {

        QImage *image = new QImage("graphics1.jpg");
        japgPalette.setBrush(QFrame::backgroundRole(), QBrush(*image));
        QFrame::setPalette(japgPalette);
        QFrame::resize(image->width(), image->height());
        move(0, 0);
        show();
    }
    else if(string.compare(QString("secondary")) == 0) {
        qDebug() << "Flag 2";
        QImage *image = new QImage("graphics2.jpg");
        japgPalette.setBrush(frame.backgroundRole(), QBrush(*image));
        frame.setPalette(japgPalette);
        frame.resize(image->width(), image->height());
        show();
   }
} I call it like this.     japgTestFrame *test = new japgTestFrame(); 
    japgTestFrame *test1 = new japgTestFrame(test);
The new frame is created and the graphics1.jpg is painting on the frame however the second image never makes it to the frame. Any ideas?
Thanks . Chris





      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091102/6312819e/attachment.html 


More information about the Qt-interest-old mailing list