Hi Guys,
I still have not figured out how to handle this. Here is a code sample. A VS project is also attached. If you make the window small and scroll the scroller horizontally and vertically, you will see the QLabel text blurring. ( I'm not sure blur is the correct word to use. )
In this example, the scroller is not really transparent ( not sure why ), but anyway that's not the point. It shows the effect I am trying to show. ( actually not show.
many thanks,
B
#include "testwindow.h"
#include <QLabel>
#include <QScrollArea>
#include <QVBoxLayout>
TestWindow
::TestWindow(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
init();
}
TestWindow::~TestWindow()
{
}
void TestWindow::init()
{
this->setStyleSheet("QDialog { background-color: blue; }");
scroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scroller->setAttribute(Qt::WA_NoBackground);
panel->setAttribute(Qt::WA_NoBackground);
scroller->setWidget(panel);
panelLayout
->setSizeConstraint
(QLayout::SetMinAndMaxSize);
panel->setLayout(panelLayout);
label->setStyleSheet("QLabel { color: red; }");
label->setText("Qt rocks!");
label->setMinimumSize(600, 600);
QFont font
("Courier",
24);
label->setFont(font);
panelLayout->addWidget(label);
layout->addWidget(scroller);
setLayout(layout);
}
#include "testwindow.h"
#include <QLabel>
#include <QScrollArea>
#include <QVBoxLayout>
TestWindow::TestWindow(QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags)
{
ui.setupUi(this);
init();
}
TestWindow::~TestWindow()
{
}
void TestWindow::init()
{
this->setStyleSheet("QDialog { background-color: blue; }");
QVBoxLayout* layout = new QVBoxLayout(this);
QScrollArea* scroller = new QScrollArea(this);
scroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scroller->setAttribute(Qt::WA_NoBackground);
QWidget* panel = new QWidget(this);
panel->setAttribute(Qt::WA_NoBackground);
scroller->setWidget(panel);
QHBoxLayout* panelLayout = new QHBoxLayout(this);
panelLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
panel->setLayout(panelLayout);
QLabel* label = new QLabel(this);
label->setStyleSheet("QLabel { color: red; }");
label->setText("Qt rocks!");
label->setMinimumSize(600, 600);
QFont font("Courier", 24);
label->setFont(font);
panelLayout->addWidget(label);
layout->addWidget(scroller);
setLayout(layout);
}
To copy to clipboard, switch view to plain text mode
Bookmarks