1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

fix svg widget qt4 build

This commit is contained in:
tianduanrui 2017-11-18 11:38:00 +08:00
parent 55897af10d
commit b1c56960a6
12 changed files with 56 additions and 39 deletions

View File

@ -36,15 +36,12 @@ MainWindow::MainWindow ( QWidget* parent ) :
"/Users/abel/Develop/d1-product/App/skin/default/bt_stir_press.svg" );
ui->p0->setRange ( 0, 100 );
ui->p0->setValue ( 60 );
QTimer* timer = new QTimer ( this );
timer->setInterval ( 100 );
timer->setSingleShot ( false );
QObject::connect ( timer, &QTimer::timeout,
[this]
{
static int i = 0;
ui->p0->setValue ( i++ % 100 );
} ) ;
QObject::connect ( timer, SIGNAL ( timeout() ),
this, SLOT ( updateProgress() ) ) ;
timer->start();
}
@ -52,3 +49,9 @@ MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::updateProgress()
{
static int i = 0;
ui->p0->setValue ( i++ % 100 );
}

View File

@ -12,11 +12,14 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
explicit MainWindow ( QWidget* parent = 0 );
~MainWindow();
private slots:
void updateProgress();
private:
Ui::MainWindow *ui;
Ui::MainWindow* ui;
};
#endif // MAINWINDOW_H

View File

@ -3,13 +3,14 @@
#include <QGraphicsSvgItem>
#include <qqt-local.h>
#include <qqtcore.h>
class QQTSHARED_EXPORT QQtGraphicsSvgItem : public QGraphicsSvgItem
{
Q_OBJECT
public:
explicit QQtGraphicsSvgItem(QQtGraphicsSvgItem* parent = nullptr);
explicit QQtGraphicsSvgItem(const QString& fileName, QQtGraphicsSvgItem* parentItem = nullptr);
explicit QQtGraphicsSvgItem ( QQtGraphicsSvgItem* parent = nullptr );
explicit QQtGraphicsSvgItem ( const QString& fileName, QQtGraphicsSvgItem* parentItem = nullptr );
signals:

View File

@ -5,12 +5,13 @@
#include <QSvgRenderer>
#include <qqtwidgets.h>
#include <qqt-local.h>
#include <qqtcore.h>
class QQTSHARED_EXPORT QQtSvgCheckBox : public QQtCheckBox
{
Q_OBJECT
public:
explicit QQtSvgCheckBox(QWidget* parent = nullptr);
explicit QQtSvgCheckBox ( QWidget* parent = nullptr );
/**
* @brief renderToVariable
@ -23,7 +24,7 @@ public slots:
// QWidget interface
protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void paintEvent ( QPaintEvent* event ) override;
private:
QSvgRenderer r[BTN_MAX];
};

View File

@ -2,32 +2,37 @@
#include <QStylePainter>
#include <QStyleOptionFrame>
QQtSvgLabel::QQtSvgLabel(QWidget* parent) : QQtLabel(parent)
QQtSvgLabel::QQtSvgLabel ( QWidget* parent ) : QQtLabel ( parent )
{
}
void QQtSvgLabel::setSvgFile(QString& filename)
void QQtSvgLabel::setSvgFile ( QString& filename )
{
mSvgRender.load(filename);
mSvgRender.load ( filename );
}
void QQtSvgLabel::setSvgContent(QByteArray& bytes)
void QQtSvgLabel::setSvgContent ( QByteArray& bytes )
{
mSvgRender.load(bytes);
mSvgRender.load ( bytes );
}
void QQtSvgLabel::paintEvent(QPaintEvent* event)
void QQtSvgLabel::paintEvent ( QPaintEvent* event )
{
Q_UNUSED(event)
Q_UNUSED ( event )
QStylePainter p(this);
if (mSvgRender.isValid())
mSvgRender.render(&p);
QStylePainter p ( this );
if ( mSvgRender.isValid() )
mSvgRender.render ( &p );
bool enabled = isEnabled();
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
p.drawItemText ( rect(), alignment(), palette(), enabled, text() );
#else
QStyleOptionFrame opt;
initStyleOption(&opt);
p.drawItemText(rect(), alignment(), opt.palette, enabled, text());
initStyleOption ( &opt );
p.drawItemText ( rect(), alignment(), opt.palette, enabled, text() );
#endif
}

View File

@ -4,15 +4,16 @@
#include <qqtlabel.h>
#include <QSvgRenderer>
#include <qqt-local.h>
#include <qqtcore.h>
class QQTSHARED_EXPORT QQtSvgLabel : public QQtLabel
{
Q_OBJECT
public:
explicit QQtSvgLabel(QWidget* parent = nullptr);
explicit QQtSvgLabel ( QWidget* parent = nullptr );
void setSvgFile(QString& filename);
void setSvgContent(QByteArray& bytes);
void setSvgFile ( QString& filename );
void setSvgContent ( QByteArray& bytes );
signals:
@ -20,7 +21,7 @@ public slots:
// QWidget interface
protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void paintEvent ( QPaintEvent* event ) override;
private:
QSvgRenderer mSvgRender;

View File

@ -4,6 +4,7 @@
#include <qqtsvgwidget.h>
#include <QSvgRenderer>
#include <qqt-local.h>
#include <qqtcore.h>
class QQTSHARED_EXPORT QQtSvgProgressBar : public QQtSvgWidget
{

View File

@ -5,12 +5,13 @@
#include <QSvgRenderer>
#include <qqtwidgets.h>
#include <qqt-local.h>
#include <qqtcore.h>
class QQTSHARED_EXPORT QQtSvgPushButton : public QQtPushButton
{
Q_OBJECT
public:
explicit QQtSvgPushButton(QWidget* parent = nullptr);
explicit QQtSvgPushButton ( QWidget* parent = nullptr );
virtual ~QQtSvgPushButton() {}
/**
@ -25,7 +26,7 @@ public slots:
// QWidget interface
protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void paintEvent ( QPaintEvent* event ) override;
private:
QSvgRenderer r[BTN_MAX];

View File

@ -5,12 +5,13 @@
#include <QSvgRenderer>
#include <qqtwidgets.h>
#include <qqt-local.h>
#include <qqtcore.h>
class QQTSHARED_EXPORT QQtSvgRadioButton : public QQtRadioButton
{
Q_OBJECT
public:
explicit QQtSvgRadioButton(QWidget* parent = nullptr);
explicit QQtSvgRadioButton ( QWidget* parent = nullptr );
/**
* @brief renderToVariable
* call this function after iconTable() set.
@ -22,7 +23,7 @@ public slots:
// QWidget interface
protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void paintEvent ( QPaintEvent* event ) override;
private:
QSvgRenderer r[BTN_MAX];
};

View File

@ -3,6 +3,7 @@
#include <QSvgWidget>
#include <qqt-local.h>
#include <qqtcore.h>
class QQTSHARED_EXPORT QQtSvgWidget : public QSvgWidget
{

View File

@ -9,15 +9,15 @@ class QQTSHARED_EXPORT QQtTreeView : public QTreeView
Q_OBJECT
public:
explicit QQtTreeView(QWidget* parent = 0);
explicit QQtTreeView ( QWidget* parent = 0 );
virtual ~QQtTreeView();
private:
// QQTTreeView interface
// QQtTreeView interface
protected:
void drawRow(QPainter* painter, const QStyleOptionViewItem& options, const QModelIndex& index) const;
void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const;
void drawRow ( QPainter* painter, const QStyleOptionViewItem& options, const QModelIndex& index ) const;
void drawBranches ( QPainter* painter, const QRect& rect, const QModelIndex& index ) const;
};
#endif // QQTTREEVIEW_H

View File

@ -1,9 +1,8 @@
#include "qqttreewidget.h"
#include "ui_qqttreewidget.h"
#include "qqtxmltreemodel.h"
QQtTreeWidget::QQtTreeWidget(QWidget* parent) :
QQtTreeView(parent)
QQtTreeWidget::QQtTreeWidget ( QWidget* parent ) :
QQtTreeView ( parent )
{
}