MainWindow::MainWindow()
{
tabWidget_
= new QTabWidget();
//tabWidget_ is a member of MainWindow setCentralWidget(tabWidget_);
tabWidget_
->addTab
(new QWidget(),
"Histograms");
.....
.....
gradientWidget_ = new QWidget();
//gradientWidget_ is a member of MainWindow tabWidget_->addTab(gradientWidget_, "Gradient" );
gradient.
setColorAt(0.2,
QColor(0,
0,
255,
127));
gradient.
setColorAt(0.5,
QColor(255,
0,
0,
127));
painter_->begin(gradientWidget_);
painter_->setBrush(gradient);
painter_->setPen(Qt::NoPen);
painter_->drawRect(gradientWidget_->rect());
}
MainWindow::MainWindow()
{
tabWidget_ = new QTabWidget(); //tabWidget_ is a member of MainWindow
setCentralWidget(tabWidget_);
tabWidget_->addTab(new QWidget(), "Histograms");
.....
.....
gradientWidget_ = new QWidget(); //gradientWidget_ is a member of MainWindow
tabWidget_->addTab(gradientWidget_, "Gradient" );
Qpainter *painter_ = new QPainter();
QGradient gradient;
QPointF startPoint(10.0,10.0);
QPointF endPoint(50.0,50.0);
gradient = QLinearGradient(startPoint, endPoint);
gradient.setColorAt(0.2,QColor(0, 0, 255, 127));
gradient.setColorAt(0.5,QColor(255, 0, 0, 127));
gradient.setSpread(QGradient::PadSpread);
painter_->begin(gradientWidget_);
painter_->setBrush(gradient);
painter_->setPen(Qt::NoPen);
painter_->drawRect(gradientWidget_->rect());
}
To copy to clipboard, switch view to plain text mode
Bookmarks