Whilst the example below or above works,
this doesn't:
#ifndef BWIDGET_H
#define BWIDGET_H
#include <QWidget>
{
public:
~BWidget(){};
private:
};
#endif
#ifndef BWIDGET_H
#define BWIDGET_H
#include <QWidget>
class QLabel;
class BWidget : public QWidget
{
public:
BWidget(QWidget *parent = 0);
~BWidget(){};
private:
QLabel *_myLabel;
};
#endif
To copy to clipboard, switch view to plain text mode
#include "bwidget.h"
#include <QLabel>
{
_myLabel->setPalette(p);
_myLabel->setText("OK");
// setPalette(p);
}
#include "bwidget.h"
#include <QLabel>
BWidget::BWidget(QWidget *parent) : QWidget(parent)
{
_myLabel = new QLabel(this);
QPalette p = _myLabel->palette();
p.setColor(QPalette::Window, Qt::red);
_myLabel->setPalette(p);
_myLabel->setText("OK");
// setPalette(p);
}
To copy to clipboard, switch view to plain text mode
After the window is redrawn, the background colour of the label is displayed as desired for a split second (e.g. after it was hidden behind another window and it's shown again. You have to toggle very fast to see it, though).
But something redraws it with the standard gray.
Any ideas?
Bookmarks