Hello,
I have a problem with Q_OBJECT and background image.
#ifndef MYCLASS_HH
# define MYCLASS_HH
# include <QWidget>
{
public:
Q_OBJECT
};
#endif // MYCLASS_HH
#include "myclass.hh"
{
setStyleSheet("background-image: url(../QSS/background.png)");
}
#ifndef MYCLASS_HH
# define MYCLASS_HH
# include <QWidget>
class myclass: public QWidget
{
public:
myclass(QWidget* parent = 0);
Q_OBJECT
};
#endif // MYCLASS_HH
#include "myclass.hh"
myclass::myclass(QWidget* parent)
: QWidget(parent)
{
setStyleSheet("background-image: url(../QSS/background.png)");
}
To copy to clipboard, switch view to plain text mode
When i put in comment Q_OBJECT macro, i see my background image on my widget.
But when Q_OBJECT macro is not commented, i don't see my background image.
Why ?
I have test this code on my widget :
palette.
setBrush((this)->backgroundRole
(),
QBrush(pixmap
));
(this)->setPalette(palette);
QPalette palette;
QPixmap pixmap = QPixmap("../QSS/background.jpg");
palette.setBrush((this)->backgroundRole(), QBrush(pixmap));
(this)->setPalette(palette);
To copy to clipboard, switch view to plain text mode
It works, bug i don't see how i can use a CSS external file with this...
Thanks for you help.
Bookmarks