#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include<QtGui>
namespace Ui {
class Widget;
}
{
Q_OBJECT
public:
explicit Widget
(QWidget *parent
= 0);
~Widget();
private:
Ui::Widget *ui;
private slots:
};
#endif // WIDGET_H
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include<QtGui>
namespace Ui {
class Widget;
}
class Widget : public QWidget,QCalendarWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private:
Ui::Widget *ui;
private slots:
void paintEvent(QPaintEvent *);
};
#endif // WIDGET_H
To copy to clipboard, switch view to plain text mode
#include "widget.h"
#include "ui_widget.h"
#include<QPainter>
#include<QFont>
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
{
painter.setPen(Qt::red);
painter.setBrush(Qt::green);
painter.
setFont(QFont("Ariel",
30));
painter.drawText(rect(),Qt::AlignCenter,"Qt");
QRectF rect
(100.0,
200.0,
80.0,
60.0);
int startAngle = 50 * 16;
int spanAngle = 120 * 16;
painter.drawChord(rect, startAngle, spanAngle);
painter.fillRect(10,200,80,60,Qt::green);
painter.drawEllipse(rect);
QRectF target
(10.0,
20.0,
80.0,
60.0);
QRectF source
(10.0,
20.0,
70.0,
40.0);
QImage image
("C:/speedback.png");
painter.drawImage(target, image, source);
painter.end();
}
{
painter->save(); // save standard settings
//painter->setBrush (this->myBrush); // myBrush is a class member that store your background image
painter->setBrush(Qt::VerPattern);
QRect rect
(100,
200,
80,
60);
painter->drawEllipse(rect);
ui->calendarWidget->paintCell (painter, rect, date);
painter->restore(); // restore previous settings
}
#include "widget.h"
#include "ui_widget.h"
#include<QPainter>
#include<QFont>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(Qt::red);
painter.setBrush(Qt::green);
painter.setFont(QFont("Ariel",30));
painter.drawText(rect(),Qt::AlignCenter,"Qt");
QRectF rect(100.0, 200.0, 80.0, 60.0);
int startAngle = 50 * 16;
int spanAngle = 120 * 16;
painter.drawChord(rect, startAngle, spanAngle);
painter.fillRect(10,200,80,60,Qt::green);
painter.drawEllipse(rect);
QRectF target(10.0, 20.0, 80.0, 60.0);
QRectF source(10.0, 20.0, 70.0, 40.0);
QImage image("C:/speedback.png");
painter.drawImage(target, image, source);
painter.end();
}
void Widget::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const
{
painter->save(); // save standard settings
//painter->setBrush (this->myBrush); // myBrush is a class member that store your background image
painter->setBrush(Qt::VerPattern);
QRect rect(100, 200, 80, 60);
painter->drawEllipse(rect);
ui->calendarWidget->paintCell (painter, rect, date);
painter->restore(); // restore previous settings
}
To copy to clipboard, switch view to plain text mode
Bookmarks