#include <QtGui/QApplication>
#include "drawfrontpage.h"
int main(int argc, char *argv[])
{
DrawFrontPage w;
// DrawFrontPage m;
// QFrame *f = new QFrame(&m);
// m.setCentralWidget(f);
// m.resize(150, 150);
// m.show();
w.show();
return a.exec();
}
#include <QtGui/QApplication>
#include "drawfrontpage.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
DrawFrontPage w;
// DrawFrontPage m;
// QFrame *f = new QFrame(&m);
// m.setCentralWidget(f);
// m.resize(150, 150);
// m.show();
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
#ifndef DRAWFRONTPAGE_H
#define DRAWFRONTPAGE_H
#include <QMainWindow>
#include"QtGui"
#include"qpainter.h"
#include"QFrame"
namespace Ui {
class DrawFrontPage ;
}
{
Q_OBJECT
public:
explicit DrawFrontPage
(QWidget *parent
= 0);
~DrawFrontPage();
public:
// void QFrame::paintEvent( QPaintEvent * event );
private:
Ui::DrawFrontPage *ui;
};
#endif // DRAWFRONTPAGE_H
#ifndef DRAWFRONTPAGE_H
#define DRAWFRONTPAGE_H
#include <QMainWindow>
#include"QtGui"
#include"qpainter.h"
#include"QFrame"
namespace Ui {
class DrawFrontPage ;
}
class DrawFrontPage : public QMainWindow
{
Q_OBJECT
public:
explicit DrawFrontPage(QWidget *parent = 0);
~DrawFrontPage();
public:
void paintEvent ( QPaintEvent * event );
// void QFrame::paintEvent( QPaintEvent * event );
private:
Ui::DrawFrontPage *ui;
};
#endif // DRAWFRONTPAGE_H
To copy to clipboard, switch view to plain text mode
#include "drawfrontpage.h"
#include "ui_drawfrontpage.h"
#include"qframe.h"
int Direction=1; //0-> clockwise 1->anti Colockwise
int Angle=10;
int Temp1;
int Temp2;
DrawFrontPage
:: DrawFrontPage(QWidget *parent
) : ui(new Ui:: DrawFrontPage)
{
ui->setupUi(this);
}
DrawFrontPage::~DrawFrontPage()
{
delete ui;
}
void DrawFrontPage
::paintEvent ( QPaintEvent * event
){
// QFrame::paintEvent(event);
// ui->myframe->setSizeIncrement(10,10);
// setCentralWidget(myframe)
// setCentralWidget(myframe);
int radius = qMin(event->rect().width(), event->rect().height()) / 2;
// QPainter painter(this);
/*
QRectF rectangle(10.0, 20.0, 150.0, 150.0);
QPainter painter(this);
painter.drawEllipse(rectangle);
*/
//fix the direction for the blade
if(Direction == 0)
{
if(Angle <=180)
{
Temp1 = 0 + Angle;
Temp2= 180+ Angle;
}
else
{
Temp1 = 0 + Angle;
Temp2= 0 + (Angle-180);
}
}
else
{
if(Angle <=180)
{
Temp1 = 360 - Angle;
Temp2= 180 - Angle;
}
else
{
Temp1 = 360 -Angle;
Temp2= 360 -(Angle-180);
}
}
static const QPoint hourHand
[3] = { };
static const QPoint minuteHand
[3] = { };
QColor hourColor
(127,
0,
127);
QColor minuteColor
(127,
0,
127);
int side = qMin(width(), height());
painter.drawEllipse(event->rect().center(), radius, radius);
painter.
setRenderHint(QPainter::Antialiasing);
painter.translate(width() / 2, height() / 2);
painter.scale(side / 200.0, side / 200.0);
painter.setPen(Qt::NoPen);
painter.setBrush(hourColor);
painter.save();
painter.rotate(Temp1);
painter. drawConvexPolygon(hourHand, 3);
painter.restore();
painter.setPen(hourColor);
painter.setPen(Qt::NoPen);
painter.setBrush(minuteColor);
painter.save();
painter.rotate(Temp2);
painter.drawConvexPolygon(minuteHand, 3);
painter.restore();
painter.setPen(minuteColor);
}
#include "drawfrontpage.h"
#include "ui_drawfrontpage.h"
#include"qframe.h"
int Direction=1; //0-> clockwise 1->anti Colockwise
int Angle=10;
int Temp1;
int Temp2;
DrawFrontPage:: DrawFrontPage(QWidget *parent) :
QMainWindow(parent),
ui(new Ui:: DrawFrontPage)
{
ui->setupUi(this);
}
DrawFrontPage::~DrawFrontPage()
{
delete ui;
}
void DrawFrontPage::paintEvent ( QPaintEvent * event ){
QFrame *myframe =new QFrame(this);
// QFrame::paintEvent(event);
// ui->myframe->setSizeIncrement(10,10);
// setCentralWidget(myframe)
// setCentralWidget(myframe);
int radius = qMin(event->rect().width(), event->rect().height()) / 2;
// QPainter painter(this);
/*
QRectF rectangle(10.0, 20.0, 150.0, 150.0);
QPainter painter(this);
painter.drawEllipse(rectangle);
*/
//fix the direction for the blade
if(Direction == 0)
{
if(Angle <=180)
{
Temp1 = 0 + Angle;
Temp2= 180+ Angle;
}
else
{
Temp1 = 0 + Angle;
Temp2= 0 + (Angle-180);
}
}
else
{
if(Angle <=180)
{
Temp1 = 360 - Angle;
Temp2= 180 - Angle;
}
else
{
Temp1 = 360 -Angle;
Temp2= 360 -(Angle-180);
}
}
static const QPoint hourHand[3] = {
QPoint(7, 8),
QPoint(-7, 8),
QPoint(0, -100)
};
static const QPoint minuteHand[3] = {
QPoint(7, 8),
QPoint(-7, 8),
QPoint(0, -100)
};
QColor hourColor(127, 0, 127);
QColor minuteColor(127, 0, 127);
int side = qMin(width(), height());
QPainter painter(this);
painter.drawEllipse(event->rect().center(), radius, radius);
painter.setRenderHint(QPainter::Antialiasing);
painter.translate(width() / 2, height() / 2);
painter.scale(side / 200.0, side / 200.0);
painter.setPen(Qt::NoPen);
painter.setBrush(hourColor);
painter.save();
painter.rotate(Temp1);
painter. drawConvexPolygon(hourHand, 3);
painter.restore();
painter.setPen(hourColor);
painter.setPen(Qt::NoPen);
painter.setBrush(minuteColor);
painter.save();
painter.rotate(Temp2);
painter.drawConvexPolygon(minuteHand, 3);
painter.restore();
painter.setPen(minuteColor);
}
To copy to clipboard, switch view to plain text mode
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DrawFrontPage</class>
<widget class="QMainWindow" name="DrawFrontPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>573</width>
<height>448</height>
</rect>
</property>
<property name="windowTitle">
<string>DrawFrontPage</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QFrame" name="myframe">
<property name="geometry">
<rect>
<x>270</x>
<y>50</y>
<width>281</width>
<height>261</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DrawFrontPage</class>
<widget class="QMainWindow" name="DrawFrontPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>573</width>
<height>448</height>
</rect>
</property>
<property name="windowTitle">
<string>DrawFrontPage</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QFrame" name="myframe">
<property name="geometry">
<rect>
<x>270</x>
<y>50</y>
<width>281</width>
<height>261</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
To copy to clipboard, switch view to plain text mode
Bookmarks