Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. namespace Ui {
  2. class myButton;
  3. }
  4.  
  5. class myButton : public QPushButton
  6. {
  7. Q_OBJECT
  8.  
  9. public:
  10. explicit myButton(QWidget *parent = 0);
  11. ~myButton();
  12.  
  13. void setSize(int _xs, int _ys);
  14. void setPosition(int _xp, int _yp);
  15.  
  16. private:
  17. Ui::Tile *ui;
  18. int xSize = 95;
  19. int ySize = 95;
  20.  
  21. protected:
  22. void paintEvent(QPaintEvent *);
  23.  
  24. };
  25.  
  26. myButton::myButton(QWidget *parent) :
  27. QPushButton(parent),
  28. ui(new Ui::myButton)
  29. {
  30. ui->setupUi(this);
  31. }
  32.  
  33. myButton::~myButton()
  34. {
  35.  
  36. }
  37.  
  38. //Paint event of button
  39. void myButton::paintEvent(QPaintEvent *paint){
  40. QPushButton::paintEvent(paint);
  41. QPainter p(this);
  42. p.save();
  43.  
  44. p.drawText(QPoint(80,10),"FirstName"); // Simple Text.
  45. p.setPen(Qt::blue); // Changing the color of pen.
  46. p.setFont(QFont("Arial", 50)); // Changing the font.
  47. p.drawText(QPoint(80,20),"MiddleName");
  48. p.drawText(QPoint(80,30),"Lastname");
  49. p.restore();
  50. }
  51.  
  52. myButton *newBtn2 = new myButton(this);
  53. newBtn2->show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement