Commit 2869e857 authored by captainwong's avatar captainwong

jlibqt RndButton ok

parent 194f317c
#include "RndButton.h" #include "RndButton.h"
#include "../QtUtils.h"
#include "../QtStylesheet.h" #include "../QtStylesheet.h"
using namespace jlib::qt; using namespace jlib::qt;
RndButton::RndButton(QWidget* parent) RndButton::RndButton(QWidget* parent)
: QWidget(parent) : QWidget(parent)
{ {
...@@ -24,12 +23,6 @@ void RndButton::set_attr(QString txt, QSize sz, int font_size) ...@@ -24,12 +23,6 @@ void RndButton::set_attr(QString txt, QSize sz, int font_size)
txt_->setText(txt); txt_->setText(txt);
setFixedSize(sz); setFixedSize(sz);
/*QPixmap pixmap;
LOAD_PIXMAP_EX(QString::fromLocal8Bit(":/Skin/Ӧÿ1.png"));
QSize pixSize = pixmap.size();
pixSize.scale(sz, Qt::KeepAspectRatio);
pixmap_ = pixmap.scaled(pixSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);*/
txt_->resize(size()); txt_->resize(size());
txt_->move(0, 0); txt_->move(0, 0);
txt_->show(); txt_->show();
...@@ -51,7 +44,6 @@ void RndButton::paintEvent(QPaintEvent* e) ...@@ -51,7 +44,6 @@ void RndButton::paintEvent(QPaintEvent* e)
QPainter painter(this); QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::Antialiasing, true);
QPainterPath path; QPainterPath path;
//int radius = std::min(rect().width() / 20, rect().height() / 20);
path.addRoundedRect(QRectF(0, 0, width(), height()), 10, 10); path.addRoundedRect(QRectF(0, 0, width(), height()), 10, 10);
QPen pen(Qt::black, 1); QPen pen(Qt::black, 1);
painter.setPen(pen); painter.setPen(pen);
......
...@@ -5,15 +5,18 @@ ...@@ -5,15 +5,18 @@
//namespace HBVideoPlatform { //namespace HBVideoPlatform {
//namespace common { //namespace common {
#include <QtWidgets>
class RndButton : public QWidget class RndButton : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
RndButton(QWidget *parent); RndButton(QWidget* parent);
~RndButton(); ~RndButton();
void set_attr(QString txt, QSize btn_sz = { 60, 30 }, int font_size = 14); void set_attr(QString txt, QSize btn_sz = { 60, 30 }, int font_size = 14);
void set_highlight(bool on = true); void set_highlight(bool on = true);
protected: protected:
...@@ -37,5 +40,6 @@ private: ...@@ -37,5 +40,6 @@ private:
bool is_highlighted_ = false; bool is_highlighted_ = false;
}; };
//} //}
//} //}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment