界面完成
This commit is contained in:
32
MyButton.h
32
MyButton.h
@ -10,21 +10,42 @@
|
||||
#include <QtSvg/QtSvg>
|
||||
#include <QtSvg/QSvgWidget>
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include "globalvariables.h"
|
||||
|
||||
class MyButton: public QPushButton{
|
||||
public:
|
||||
MyButton(QString logo,QString text,int width,int height,QWidget *parent=nullptr);
|
||||
MyButton(QString logo,QString text,int width,int height,QList<MyButton *> *buttons,QWidget *parent=nullptr);
|
||||
~MyButton() override;
|
||||
QString getText(){
|
||||
return text;
|
||||
}
|
||||
QSize sizeHint() const override {
|
||||
return QSize(width2/2,height2/2);
|
||||
}
|
||||
|
||||
QSize sizeHint() const override;
|
||||
void setChecked(bool checked){
|
||||
this->checked=checked;
|
||||
}
|
||||
QSize getLogicalSize() const {
|
||||
if(scale>=1.25){
|
||||
return QSize(width2,height2);
|
||||
}
|
||||
else{
|
||||
return QSize(width2,height2);
|
||||
};
|
||||
}
|
||||
int setSize(int width,int height,int logicalwidth,int logicalheight){
|
||||
this->width2=width;
|
||||
this->height2=height;
|
||||
this->logicalwidth=logicalwidth;
|
||||
this->logicalheight=logicalheight;
|
||||
}
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void enterEvent(QEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
private:
|
||||
QList<MyButton *> *buttons;
|
||||
QImage *logo;
|
||||
QLabel *logo_label;
|
||||
QLabel *text_label;
|
||||
@ -33,6 +54,9 @@ private:
|
||||
QString text;
|
||||
int width2;
|
||||
int height2;
|
||||
int logicalwidth;
|
||||
int logicalheight;
|
||||
bool checked=false;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user