Qt 오른쪽 하단 팝 업 상자 만 들 기
이 예 는 주로 QProperty Animation 을 애니메이션 클래스 로 사용 합 니 다.
코드 를 직접 올 리 면 설명 이 잘 들 리 겠 지만,
소스 코드 다운로드 주소:http://download.csdn.net/detail/silencesu/4583309
main.cpp
#include
#include "dialog.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Dialog w;
w.show();
return a.exec();
}
dialog.h
#ifndef DIALOG_H
#define DIALOG_H
#include
#include
#include
#include
#include
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private:
Ui::Dialog *ui;
QDesktopWidget desktop;
QPropertyAnimation* animation;
QTimer *remainTimer;
void showAnimation();
private slots:
void closeAnimation();
void clearAll();
};
#endif // DIALOG_H
dialog.cpp
#include "dialog.h"
#include "ui_dialog.h"
#include
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint); //
this->move((desktop.availableGeometry().width()-this->width()),desktop.availableGeometry().height());//
showAnimation(); //
}
Dialog::~Dialog()
{
delete ui;
}
//
void Dialog::showAnimation(){
//
animation=new QPropertyAnimation(this,"pos");
animation->setDuration(2000);
animation->setStartValue(QPoint(this->x(),this->y()));
animation->setEndValue(QPoint((desktop.availableGeometry().width()-this->width()),(desktop.availableGeometry().height()-this->height())));
animation->start();
// 2 、
remainTimer=new QTimer();
connect(remainTimer,SIGNAL(timeout()),this,SLOT(closeAnimation()));
remainTimer->start(4000);// 2S, 2S
}
//
void Dialog::closeAnimation(){
// Timer
remainTimer->stop();
disconnect(remainTimer,SIGNAL(timeout()),this,SLOT(closeAnimation()));
delete remainTimer;
remainTimer=NULL;
//
animation->setStartValue(QPoint(this->x(),this->y()));
animation->setEndValue(QPoint((desktop.availableGeometry().width()-this->width()),desktop.availableGeometry().height()));
animation->start();
//
connect(animation,SIGNAL(finished()),this,SLOT(clearAll()));
}
//
void Dialog::clearAll(){
disconnect(animation,SIGNAL(finished()),this,SLOT(clearAll()));
delete animation;
animation=NULL;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
바이너리 파일cat 또는tail, 터미널 디코딩 시 처리 방법cat으로 바이너리 파일을 보려고 할 때 코드가 엉망이 되어 식은땀이 났다. 웹에서 스크롤된 정보의 처리 방법과alias의 설정을 요약합니다. reset 명령을 사용하여 터미널을 재설정합니다.이렇게 하면 고치지 못하...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.