Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Ui {
- class myButton;
- }
- class myButton : public QPushButton
- {
- Q_OBJECT
- public:
- explicit myButton(QWidget *parent = 0);
- ~myButton();
- void setSize(int _xs, int _ys);
- void setPosition(int _xp, int _yp);
- private:
- Ui::Tile *ui;
- int xSize = 95;
- int ySize = 95;
- protected:
- void paintEvent(QPaintEvent *);
- };
- myButton::myButton(QWidget *parent) :
- QPushButton(parent),
- ui(new Ui::myButton)
- {
- ui->setupUi(this);
- }
- myButton::~myButton()
- {
- }
- //Paint event of button
- void myButton::paintEvent(QPaintEvent *paint){
- QPushButton::paintEvent(paint);
- QPainter p(this);
- p.save();
- p.drawText(QPoint(80,10),"FirstName"); // Simple Text.
- p.setPen(Qt::blue); // Changing the color of pen.
- p.setFont(QFont("Arial", 50)); // Changing the font.
- p.drawText(QPoint(80,20),"MiddleName");
- p.drawText(QPoint(80,30),"Lastname");
- p.restore();
- }
- myButton *newBtn2 = new myButton(this);
- newBtn2->show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement