呵呵!一个QT通过贴图实现的模拟时钟 c文件
#include "draw.h"
#include "ui_draw.h"
#include <QPixmap>
draw::draw(QWidget *parent)
: QDialog(parent), ui(new Ui::draw)
{
ui->setupUi(this);
// this->setWindowFlags( Qt::FramelessWindowHint);
ctrlPoint.setX(this->width() / 2);
ctrlPoint.setY(this->height() / 2);
m_pixmap = QPixmap("Skin/Night Blue/main.png");
m_mainScale = this->width() /((qreal)(m_pixmap.width())) ;
m_pixmap = QPixmap("Skin/Night Blue/hour.png");
m_hourScale = (this->width()/(qreal)2.0 ) / (m_pixmap.width()) ;
m_pixmap = QPixmap("Skin/Night Blue/min.png");
m_minScale = (this->width()/(qreal)1.8 ) / (m_pixmap.width()) ;
m_pixmap = QPixmap("Skin/Night Blue/sec.png");
m_secScale = (this->width()/(qreal)1.5 ) / (m_pixmap.width()) ;
// qDebug("m_mainScale = %f , m_hourScale = %f , m_minScale = %f ,m_secScale = %f",m_mainScale,m_hourScale,m_minScale,m_secScale);
m_secRotation = QTime::currentTime ().second() *6 - 90;
m_minRotation = QTime::currentTime ().minute() *6 - 90;
m_hourRotation = m_minRotation / 10 + QTime::currentTime ().hour() * 30 - 90;
upTimer = new QTimer(this);
connect(upTimer,SIGNAL(timeout()),this,SLOT(updataTime()));
upTimer->start(500);
}
draw::~draw()
{
delete ui;
}
void draw::paintEvent(QPaintEvent *event)
{
//face
QPainter painter(this);
m_pixmap = QPixmap("Skin/Night Blue/main.png");
painter.scale(m_mainScale,m_mainScale);
painter.drawPixmap(QPointF(0, 0), m_pixmap);
//hour
QPainter p
相关文档:
http://c.chinaitlab.com/c/basic/200907/789321.html
词法陷阱:
1 = 不同于==不要在程序中将两者写错,小心。将表达式与常量比较时,可将常量放在左边。
2 &和| 不同于& ......
http://topic.csdn.net/u/20080924/15/3b00a84e-970f-4dea-92f2-868c5d1ad825.html?52694
前段时间刚参加了n多公司的C/C++软件工程师的面试,有国企,外企,私企(moto,飞思卡尔,港湾,中国卫星XXX(这个牛))等等等等。感受感想颇多,近日终于空闲,在此表述一下。
本人基本条件:3年开发经验,2year+ ......
面试时被问到过,不甚明了,网上百度一下,整合了两个仁兄的文章,如下。:-)
时常在cpp的代码之中看到这样的代码:
#ifdef __cplusplus //c++编译环境中才会定义__cplusplus (plus就是"+"的意思)
extern "C" { //告诉编译器下面的函数是c语言函数(因为c++和c语言对函数的编译转换不一样,主要是c++中存在重载)
#en ......
// backlightDlg.cpp : implementation file
//
#include "stdafx.h"
#include "backlight.h"
#include "backlightDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CbacklightDlg dialog
CbacklightDlg::CbacklightDlg(CWnd* pParent /*=NULL*/)
: CDialog(CbacklightDlg::IDD, pParent)
{
......