Esempio n. 1
0
void MainWindow::paintEvent(QPaintEvent *event)
{
    QBitmap objBitmap(size());//生成一张位图
    QPainter painter(&objBitmap); //QPainter用于在位图上绘画
    painter.fillRect(rect(),Qt::white);//填充位图矩形框(用白色填充)
    painter.setBrush(QColor(0,0,0));
    painter.drawRoundedRect(this->rect(),10,10); //在位图上画圆角矩形(用黑色填充)
    setMask(objBitmap); //使用setmask过滤即可
    QFrame::paintEvent(event);
}
Esempio n. 2
0
void MainWindow::redrawBorders()
{
    QBitmap objBitmap(size());
    QPainter painter;
    QRect rect(position(), QPoint(position().x() + width(), position().y() + height()));
    painter.fillRect(rect,Qt::white);
    painter.setBrush(QColor(0,0,0));
    painter.drawRoundedRect(rect,10,10);
    setMask(objBitmap);
}
Esempio n. 3
0
infarredsimulation::infarredsimulation(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::infarredsimulation)
{
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);
    movie =new QMovie(":/images/red.gif");
    ui->label->setMovie(movie);
//    people=new QPixmap(":/people.png");
    //movie->start();
    //生成一张位图
    QBitmap objBitmap(size());
    //QPainter用于在位图上绘画
    QPainter painter(&objBitmap);
    //填充位图矩形框(用白色填充)
    painter.fillRect(rect(),Qt::white);
    painter.setBrush(QColor(0,0,0));
    //在位图上画圆角矩形(用黑色填充)
    painter.drawRoundedRect(this->rect(),10,10);
    //使用setmask过滤即可
    setMask(objBitmap);
    setMinimumWidth(850);
    setMinimumHeight(600);
    this->isPortOpen=false;
    serialport=new QSerialPort;

    if(isPortOpen){
     //停止读取数据
     readTimer.stop();
     serialport->close();
     this->isPortOpen=false;
    }
    else
    {
        //设置设备号
        foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
        {
            serialport->setPortName(info.portName());
        }
        serialport->open(QIODevice::ReadWrite);
        serialport->setBaudRate(9600);
        //设置数据位
        serialport->setDataBits((QSerialPort::DataBits)(8));
        //设置停止位
        serialport->setStopBits((QSerialPort::StopBits)(1));
        //校验
        serialport->setParity((QSerialPort::Parity)(0));//23333333
        this->isPortOpen=true;
        char send[2]={0x09,0xff};
        serialport->write(send);
        readTimer.start(200);//每隔2ms
        connect(&readTimer,SIGNAL(timeout()),this,SLOT(readSlot()));
        //连接设备
    }
Esempio n. 4
0
void LoginDialog::paintEvent(QPaintEvent*){
	QBitmap objBitmap(size());
	QPainter painter(&objBitmap);
	painter.setBrush(QColor(0, 0, 0));
	painter.drawRoundedRect(this->rect(), 10, 10);
	setMask(objBitmap);
	QPainter painter2(this);
	QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin);
	painter2.setPen(pen);
	QBrush brush(Qt::blue);
	brush.setStyle(Qt::HorPattern);
	painter2.setBrush(brush);
	painter2.drawRect(0, 0, size().width() - 1, size().height() - 1);
}
Esempio n. 5
0
Complex::Complex(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Complex)
{
    ui->setupUi(this);

    //生成一张位图
    QBitmap objBitmap(size());
    //QPainter用于在位图上绘画
    QPainter painter(&objBitmap);
    //填充位图矩形框(用白色填充)
    painter.fillRect(rect(),Qt::white);
    painter.setBrush(QColor(0,0,0));
    //在位图上画圆角矩形(用黑色填充)
    painter.drawRoundedRect(this->rect(),10,10);
    //使用setmask过滤即可
    setMask(objBitmap);
    setMinimumWidth(850);
    setMinimumHeight(600);
    this->isPortOpen=false;
    serialport=new QSerialPort;
    if(isPortOpen){
        //停止读取数据
        readTimer.stop();
        serialport->close();
        this->isPortOpen=false;
    }
    else
    {
    //设置设备号
        foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
           {

            serialport->setPortName(info.portName());
        }

    serialport->open(QIODevice::ReadWrite);


    serialport->setBaudRate(9600);
    //设置数据位
    serialport->setDataBits((QSerialPort::DataBits)(8));
    //设置停止位
    serialport->setStopBits((QSerialPort::StopBits)(1));
    //校验
    serialport->setParity((QSerialPort::Parity)(0));//23333333
    this->isPortOpen=true;

    readTimer.start(200);//每隔200ms
}
Esempio n. 6
0
void MainFrame::setWindowCircle()
{
    //生成一张位图
    QBitmap objBitmap(size());
    //QPainter用于在位图上绘画
    QPainter painter(&objBitmap);
    //填充位图矩形框(用白色填充)
    painter.fillRect(rect(),Qt::white);
    painter.setBrush(QColor(0,0,0));
    //在位图上画圆角矩形(用黑色填充)
    painter.drawRoundedRect(this->rect(),10,10);
    //使用setmask过滤即可
    setMask(objBitmap);
}
Esempio n. 7
0
buttonDemonstrate::buttonDemonstrate(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::buttonDemonstrate)
{
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);
    QBitmap objBitmap(size());
    //QPainter用于在位图上绘画
    QPainter painter(&objBitmap);
    //填充位图矩形框(用白色填充)
    painter.fillRect(rect(),Qt::white);
    painter.setBrush(QColor(0,0,0));
    //在位图上画圆角矩形(用黑色填充)
    painter.drawRoundedRect(this->rect(),10,10);
    //使用setmask过滤即可
    setMask(objBitmap);
    this->isPortOpen=false;
    serialport = new QSerialPort;
    this->isPortOpen=false;
    serialport=new QSerialPort;

    if(isPortOpen){
        //停止读取数据
        readTimer.stop();
        serialport->close();
        this->isPortOpen=false;
    }
    else
    {
        //设置设备号
        foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
        {
            serialport->setPortName(info.portName());
        }
        serialport->open(QIODevice::ReadWrite);
        serialport->setBaudRate(4800);
        //设置数据位
        serialport->setDataBits((QSerialPort::DataBits)(8));
        //设置停止位
        serialport->setStopBits((QSerialPort::StopBits)(1));
        //校验
        serialport->setParity((QSerialPort::Parity)(0));//23333333
        this->isPortOpen=true;
        char send[2]={0x12,0xff};
        serialport->write(send);
        readTimer.start(200);//每隔2ms
        connect(&readTimer,SIGNAL(timeout()),this,SLOT(readSlot()));
        //连接设备
    }
Esempio n. 8
0
logIn::logIn( QWidget * parent,Qt::WindowFlags):QDialog(parent,Qt::FramelessWindowHint)
{
	//setWindowTitle(QObject::tr("登陆界面"));
	QDesktopWidget *desktop = QApplication::desktop();  
	setGeometry(desktop->width()/3,desktop->height()/2,400,200);//设置窗口的位置和大小
	//setWindowFlags(Qt::FramelessWindowHint);	//创建无边框的窗口
	m_pTitle = new QLabel;
	m_pIcon = new QLabel;
	m_pPwd = new QLabel(QObject::tr("密码"));
	m_pUser = new QLabel(QObject::tr("用户名"));
	m_pPwdEdit = new QLineEdit;
	m_pUserEdit = new QLineEdit;
	m_pLogBtn = new QPushButton(QObject::tr("登陆"));
	m_pQuitBtn = new QPushButton(QObject::tr("退出"));

	m_pTitle->setText(QObject::tr("系统登陆界面"));
	m_pTitle->setAlignment(Qt::AlignHCenter);
	//m_pIcon->setPixmap(QPixmap(":/data/logIcon"));
	//m_pIcon->resize(1,1);
	
	//创建水平布局管理器
	//QHBoxLayout * m_pTitleLayout = new QHBoxLayout;
	//m_pTitleLayout->setSpacing(0);
	//m_pTitleLayout->addWidget(m_pIcon);
	//m_pTitleLayout->addWidget(m_pTitle);

	//创建网格布局管理器
	QGridLayout *m_pGridLayout = new QGridLayout;
	m_pGridLayout->setSpacing(10);
	m_pGridLayout->setMargin(20);
	m_pGridLayout->addWidget(m_pUser,0,1,1,2);
	m_pGridLayout->addWidget(m_pUserEdit,0,3,1,3);
	m_pGridLayout->addWidget(m_pPwd,1,1,1,2);
	m_pGridLayout->addWidget(m_pPwdEdit,1,3,1,3);

	//创建水平按键布局管理器
	QHBoxLayout *btnLayout = new QHBoxLayout;
	btnLayout->setMargin(20);
	btnLayout->setSpacing(20);//内部控件间隔为20像素水平
	btnLayout->addWidget(m_pLogBtn);
	btnLayout->addWidget(m_pQuitBtn);

	//创建垂直主布局管理器
	QVBoxLayout *m_pMainLayout = new QVBoxLayout;
	//m_pMainLayout->setSpacing(0);
	//m_pMainLayout->setContentsMargins(0,0,0,0);
	m_pMainLayout->addWidget(m_pTitle);
	//m_pMainLayout->addLayout(m_pTitleLayout);
	//m_pMainLayout->stretch(40);
	m_pMainLayout->addLayout(m_pGridLayout);
	//m_pMainLayout->stretch(20);
	m_pMainLayout->addLayout(btnLayout);
	setLayout(m_pMainLayout);

	/*以下代码实现圆角矩形的窗口*/

	//生成一张位图
	QBitmap objBitmap(size());
	//QPainter用于在位图上绘画
	QPainter painter(&objBitmap); 
	//填充位图矩形框(用白色填充)
	painter.fillRect(rect(),Qt::white);
	painter.setBrush(QColor(0,0,0));
	//在位图上画圆角矩形(用黑色填充)
	painter.drawRoundedRect(this->rect(),10,10);
	//使用setmask过滤即可
	setMask(objBitmap);

	connect(m_pLogBtn,SIGNAL(clicked()),this,SLOT(accept()));
	connect(m_pQuitBtn,SIGNAL(clicked()),this,SLOT(close()));
}
Esempio n. 9
0
lightDemonstrate::lightDemonstrate(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::lightDemonstrate)
{
    ui->setupUi(this);

//    QMovie *daytonight = new QMovie(":/im/day_to_night.gif");
//    QMovie *nighttoday = new QMovie(":/im/night_to_day.gif");

//    QTimer *timer = new QTimer();
//    connect(timer,SIGNAL(timeout()),this,SLOT(stopMovie()));
//    timer->setSingleShot(true);

//    ui->label->setMovie(daytonight);
//    ui->label->movie()->start();

//    QTimer *timer = new QTimer();
//    connect(timer,SIGNAL(timeout()),this,SLOT(stopMovie()));
//    timer->setSingleShot(true);
//    timer->start(1100);
    lastState = 0;
    //生成一张位图
    QBitmap objBitmap(size());
    //QPainter用于在位图上绘画
    QPainter painter(&objBitmap);
    //填充位图矩形框(用白色填充)
    painter.fillRect(rect(),Qt::white);
    painter.setBrush(QColor(0,0,0));
    //在位图上画圆角矩形(用黑色填充)
    painter.drawRoundedRect(this->rect(),10,10);
    //使用setmask过滤即可
    setMask(objBitmap);
    setMinimumWidth(850);
    setMinimumHeight(600);
    this->isPortOpen=false;
    serialport=new QSerialPort;
    if(isPortOpen){
        //停止读取数据
        readTimer.stop();
        serialport->close();
        this->isPortOpen=false;
    }
    else
    {
        //设置设备号
        foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
        {
            serialport->setPortName(info.portName());
        }
        serialport->open(QIODevice::ReadWrite);
        serialport->setBaudRate(9600);
        //设置数据位
        serialport->setDataBits((QSerialPort::DataBits)(8));
        //设置停止位
        serialport->setStopBits((QSerialPort::StopBits)(1));
        //校验
        serialport->setParity((QSerialPort::Parity)(0));//23333333
        this->isPortOpen=true;
        char send[2]={0x08,0xff};
        serialport->write(send);
        readTimer.start(200);//每隔200ms
    }
Esempio n. 10
0
ChineseCalendar::ChineseCalendar(QWidget *parent)
    : QWidget(parent)
{
    setupUi(this); m_strFileList.clear();
//    bg = new QPixmap(":/img/chinesecalendarBGyellow.png");
    icon = QIcon(":/img/icon.png");
    icon64 = QIcon(":/img/chinesecalendar-64.png");

    mycalendat=new CCBO;
    mycalendat->InitConnection(QDir::currentPath ());
    selectedDate = QDate::currentDate();
	monthCombo->setCurrentIndex(selectedDate.month() - 1);
    YearSelect->setCurrentIndex(selectedDate.year()-1900);

    connect(monthCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setMonth(int)));
    connect(monthCombo, SIGNAL(activated(int)), this, SLOT(setMonth(int)));
    connect(YearSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(setYear(int)));
    connect(this->backtotoday, SIGNAL(clicked()), this, SLOT(backtoday()));

//    this->TbnextMonth->setStyleSheet("QPushButton{background-color:transparent;color:rgb(200,200,150);}QPushButton:hover{color:rgb(255,255,255);}");
//    this->TbnextYear->setStyleSheet("QPushButton{background-color:transparent;color:rgb(200,200,150);}QPushButton:hover{color:rgb(255,255,255);}");
//    this->TbpreviousMonth->setStyleSheet("QPushButton{background-color:transparent;color:rgb(200,200,150);}QPushButton:hover{color:rgb(255,255,255);}");
//    this->TbpreviousYear->setStyleSheet("QPushButton{background-color:transparent;color:rgb(200,200,150);}QPushButton:hover{color:rgb(255,255,255);}");
//    this->backtotoday->setStyleSheet("QPushButton{background-color:transparent;color:rgb(200,200,150);}QPushButton:hover{color:rgb(255,255,255);}");
//    this->YearSelect->setStyleSheet("QComboBox{border: 2px solid lightgray;border-radius: 5px;font:12pt;}");
//    this->monthCombo->setStyleSheet("QComboBox{border: 2px solid lightgray;border-radius: 5px;font:12pt;}");
//    this->label->setStyleSheet("QLabel{font:12pt;}");
//    this->label_2->setStyleSheet("QLabel{font:12pt;}");

    QString week;
    QDateTime dateTime = QDateTime::currentDateTime();

    if (dateTime.toString("ddd") == "Mon")
        week = "星期一"; // Monday
    else if (dateTime.toString("ddd") == "Tue")
        week = "星期二"; // Tuesday
    else if (dateTime.toString("ddd") == "Wed")
        week = "星期三"; // Wednesday
    else if (dateTime.toString("ddd") == "Thu")
        week = "星期四"; // Thursday
    else if(dateTime.toString("ddd") == "Fri")
        week = "星期五"; // Friday
    else if (dateTime.toString("ddd") == "Sat")
        week = "星期六"; // Saturday
    else
        week = "星期日"; // Sunday

    QString currentTime = dateTime.toString("yyyy-MM-dd %1").arg(week);
    QDate day = QDate::currentDate();
    struct CCalendar datebase;
    mycalendat->ctcl_solar_to_lunar(day.year(),day.month(),day.day(),&datebase);
    QString chinesemonth = datebase.cmonth;

    if (chinesemonth == "一月")
        chinesemonth = "正月";
    if (chinesemonth == "十一月")
        chinesemonth = "冬月";
    if (chinesemonth == "十二月")
        chinesemonth = "腊月";

    QString chineseday = QString("农历 %1%2").arg(chinesemonth).arg(datebase.cday);
    QString chineseyear = QString("%1年(%2年)").arg(datebase.ganzhi).arg(datebase.shengxiao);

    QString chineseyi = QString("%1").arg(datebase.yi);
    QStringList chineseyilist = chineseyi.split("、");
    QString chineseji = QString("%2").arg(datebase.ji);
    QStringList chinesejilist = chineseji.split("、");

    QFont font;
    QPalette pa;
    font.setPointSize(48);
    font.setBold(true);
    this->label_10->setFont(font);
    this->label_10->setText(QString::number(day.day()));
    font.setBold(false);
    font.setPointSize(9);
    this->label_12->setFont(font);
    this->label_12->setText(currentTime);
    font.setPointSize(10);
    this->label_13->setFont(font);
    this->label_13->setText(chineseday);
    this->label_14->setFont(font);
    this->label_14->setText(chineseyear);
    font.setPointSize(15);
    this->label_15->setFont(font);
    font.setPointSize(10);
    this->label_17->setFont(font);
    this->label_18->setFont(font);

    QString yi=QString("");
    QString ji=QString("");
    if(chineseyilist.count() == 0 )
       yi =QString("");
    if(chineseyilist.count() >= 5)
       yi = QString("").append(chineseyilist.at(0)).append("\n").append(chineseyilist.at(1)).append("\n").append(chineseyilist.at(2)).append("\n").append(chineseyilist.at(3)).append("\n").append(chineseyilist.at(4));
    if(chineseyilist.count() == 4)
       yi = QString("").append(chineseyilist.at(0)).append("\n").append(chineseyilist.at(1)).append("\n").append(chineseyilist.at(2)).append("\n").append(chineseyilist.at(3));
    if (chineseyilist.count() == 3)
       yi = QString("").append(chineseyilist.at(0)).append("\n").append(chineseyilist.at(1)).append("\n").append(chineseyilist.at(2));
    if (chineseyilist.count() == 2)
       yi = QString("").append(chineseyilist.at(0)).append("\n").append(chineseyilist.at(1));
    if (chineseyilist.count() == 1)
       yi = QString("").append(chineseyilist.at(0)).append("\n");
    this->label_17->setText(yi);

    if(chinesejilist.count() == 0 )
       ji =QString("");
    if(chinesejilist.count() >= 5)
       ji = QString("").append(chinesejilist.at(0)).append("\n").append(chinesejilist.at(1)).append("\n").append(chinesejilist.at(2)).append("\n").append(chinesejilist.at(3)).append("\n").append(chinesejilist.at(4));
    if(chinesejilist.count() == 4)
       ji = QString("").append(chinesejilist.at(0)).append("\n").append(chinesejilist.at(1)).append("\n").append(chinesejilist.at(2)).append("\n").append(chinesejilist.at(3));
    if (chinesejilist.count() == 3)
       ji = QString("").append(chinesejilist.at(0)).append("\n").append(chinesejilist.at(1)).append("\n").append(chinesejilist.at(2));
    if (chinesejilist.count() == 2)
       ji = QString("").append(chinesejilist.at(0)).append("\n").append(chinesejilist.at(1));
    if (chinesejilist.count() == 1)
       ji = QString("").append(chinesejilist.at(0)).append("\n");
    this->label_18->setText(ji);

    QString cnote=mycalendat->ctcl_displaydata(day.year(),day.month(),day.day());
    QString haveplan=QString("今日有行程安排");
    QString noplan=QString("今日无行程安排");
    int num = cnote.count();
    while (num > 0 && cnote.at(num-1).isSpace())
    {
        num--;
    }

    if(cnote.isEmpty() || num == 0)
        this->label_19->setText(noplan);
    else
        this->label_19->setText(haveplan);

    pa.setColor(QPalette::WindowText,Qt::white);
    this->label->setPalette(pa);
    this->label_2->setPalette(pa);
    this->label_15->setPalette(pa);
    this->label_4->setPalette(pa);
    this->label_5->setPalette(pa);
    this->label_6->setPalette(pa);
    this->label_7->setPalette(pa);
    this->label_8->setPalette(pa);

    pa.setColor(QPalette::WindowText,QColor(255,255,255));
    this->label_3->setPalette(pa);
    this->label_9->setPalette(pa); 

    pa.setColor(QPalette::WindowText,Qt::black);
    this->label_18->setPalette(pa);

    pa.setColor(QPalette::WindowText,QColor(235,74,20));
    this->label_10->setPalette(pa);
    this->label_12->setPalette(pa);
    this->label_13->setPalette(pa);
    this->label_14->setPalette(pa);

    pa.setColor(QPalette::WindowText,Qt::white);
    this->label_19->setPalette(pa);

    pa.setColor(QPalette::WindowText,Qt::red);
    this->label_11->setPalette(pa);
    this->label_17->setPalette(pa);

    map = new QMap<QString, DateItem *>();

    for (int i = 1; i <= 6; i++)
    {
        for (int j = 1; j <= 7; j++)
        {
            DateItem *dateitem = new DateItem(this);
            if (i <= 5)
            {
                dateitem->show();
            }
            else
            {
                dateitem->hide();
            }

            map->insert(QString("%1-%2").arg(i).arg(j), dateitem);

            if ((i < 6) || (i == 6 && (j == 1 || j == 2)))
            {
                connect(dateitem, SIGNAL(clicked(QString)), this, SLOT(resetcalendardate(QString)));
                connect(dateitem, SIGNAL(day(QString)), this, SLOT(setclickday(QString)));
                connect(dateitem, SIGNAL(resetColor()), this, SLOT(resetDateItemColor()));
            }
        }
    }

    setItemLayout();
    setCalendar();

    QTimer *timer = new QTimer(this);
    timer->setInterval(1000);
    connect(timer,SIGNAL(timeout()),this,SLOT(setTime()));
    timer->start();

    QBitmap objBitmap(size());
    QPainter painter(&objBitmap);
    painter.fillRect(rect(),Qt::white);
    painter.setBrush(QColor(0,0,0));
    painter.drawRoundedRect(this->rect(),10,10);
    setMask(objBitmap);

    aboutDlg = new AboutDialog();
    aboutDlg->hide();

    this->createTray();

    note = new Cnote;
    QDesktopWidget desktop;
    int width = desktop.screenGeometry().width();
    note->setGeometry(QRect(width-400,80,224,280));
    connect(note,SIGNAL(save(QString)),this,SLOT(savedata(QString)));
    note->hide();
}