Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as C++ by registered user raphael ( 1 year ago )
#ifndef PUSHBUTTONROUGE_H
#define PUSHBUTTONROUGE_H

#include <QPushButton>

class PushButtonRouge : public QPushButton
{
public:
    PushButtonRouge(QWidget *parent);
protected:
    void paintEvent(QPaintEvent *event) override;
};

#endif // PUSHBUTTONROUGE_H
//---------------------------------------------------------------------------
#include "pushbuttonrouge.h"
#include <QPainter>
#include <QPaintEvent>

PushButtonRouge::PushButtonRouge(QWidget *parent) : QPushButton(parent)
{

}

void PushButtonRouge::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);


    painter.fillRect(event->rect(), Qt::red);


    painter.setPen(Qt::green);
    painter.drawText(rect(), Qt::AlignCenter, text());
}
//-------------------------------------------------------------------------------------------------
#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setStyleSheet("background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 blue, stop:0.5 white, stop:1 red);");

}

MainWindow::~MainWindow()
{
    delete ui;
}

 

Revise this Paste

Children: 126239
Your Name: Code Language: