KM
Katty MisikOct. 8, 2020, 2:10 a.m.
Qt animation c++ класс для анимации, с чего начать?
animation, qt, c++, abstractanimation
Здравствуйте,
хочу сделать класс для анимации так чтобы там обрабатывалось как можно больше информации, просто у меня есть куча виджетов а писать анимацию в каждом из них помоему не рационально, вот пример одного виджета с анимацией:
#include "pinpoint.h" #include "ui_pinpoint.h" #include <QPropertyAnimation> #include <interfaces/fastproxystyle.h> #include <QGraphicsColorizeEffect> Connection& PinPoint::getConnection() { return connection; } int PinPoint::getId() const { return id; } void PinPoint::setId(int value) { id = value; } PinPoint::PinPoint(QWidget *parent) : QWidget(parent), connection(nullptr), ui(new Ui::PinPoint), notConnected("пункт", "ошибка", Error::Priority::CriticalError, true), zoneViolation("сигнализация", "нарушение", Error::Priority::CriticalError, true,true,true,"трубует проверки на месте") { ui->setupUi(this); this->layout()->setAlignment(ui->label, Qt::AlignCenter); connect(ui->pin, &PointShape::mouseOver, this, &PinPoint::mouseOverPin); connect(ui->pin, &PointShape::setupDeclared, this, &PinPoint::setupDeclared); connect(&connection, &Connection::currentStateUpdated, this, &PinPoint::updateState); connect(&connection, &Connection::updateView, this, &PinPoint::updateView); connect(&connection.getZonesWidget(), &ZonesListWidget::updateDB, this, &PinPoint::onUpdateEmit); this->setStyle(new FastProxyStyle(this->style())); connect(ui->pin, &PointShape::mouseOver1, this, &PinPoint::NoWidget); } void PinPoint::fillSetup(const QString& address, const QString& name) { setIP(address); setName(name); connection.setConnectionData(getIP(), 7094); } void PinPoint::updateState(CustomState *state, QList<Zone*> source){ if(!source.isEmpty()) { if(state==&connection.getZonesWidget().alarm || state==&connection.getZonesWidget().silentAlarm) { QString helpString=""; foreach(auto item, source) { helpString+=item->getId()+" "; } zoneViolation.setSource(this->getText()); zoneViolation.setValue("проблема "+this->getText()+" (IP: "+this->getIP().toString()+"). в "+state->getName()+" пунктах: "+helpString); generateError(zoneViolation); } else cancelError(zoneViolation); } ui->pin->setState(*state); refreshHint(); } void PinPoint::updateView(const QHostAddress& address, uint16_t port) { ui->label_2->setText(address.toString()); Q_UNUSED(port) } void PinPoint::onUpdateEmit() { emit(updateDatabase(*this)); } void PinPoint::setPos(const QPointF &pos) { position = pos; this->move(Converter::toPointToMiddle(position, size())); } bool PinPoint::isFakeElement() { return (getIP().toString()=="0.0.0.0"); } void PinPoint::mouseOverPin(){ raise(); if(!isFakeElement()) emit mouseOverMe(); QGraphicsColorizeEffect *eEffect= new QGraphicsColorizeEffect(ui->label); ui->label->setGraphicsEffect(eEffect); QPropertyAnimation *paAnimation = new QPropertyAnimation(eEffect,"color"); paAnimation->setStartValue(QColor(Qt::darkBlue)); paAnimation->setEndValue(QColor(Qt::red)); paAnimation->setDuration(1000); paAnimation->start(); } void PinPoint::NoWidget() { QGraphicsColorizeEffect *eEffect= new QGraphicsColorizeEffect(ui->label); ui->label->setGraphicsEffect(eEffect); QPropertyAnimation *paAnimation = new QPropertyAnimation(eEffect,"color"); paAnimation->setStartValue(QColor(Qt::red)); paAnimation->setEndValue(QColor(Qt::darkBlue)); paAnimation->setDuration(1000); paAnimation->start(); } void PinPoint::setName(const QString &text) { ui->label->setText(text); notConnected.setSource(text); notConnected.setValue("сигнализация на обьекте "+text+" (ip:"+getIP().toString()+")!"); } void PinPoint::refreshHint() { this->setToolTip("название: "+ui->label->text()+"\nIP: "+this->getIP().toString()+"\n"+connection.getZonesWidget().getInfoString()); } void PinPoint::setIP(const QString& ip) { connection.setCentralAddress(QHostAddress(ip)); ui->label_2->setText(ip); refreshHint(); } PinPoint::~PinPoint(){delete ui;} QPointF PinPoint::getPos() {return position;} QString PinPoint::getText() {return this->ui->label->text();} QString PinPoint::getStateString(){return ui->pin->getStateString();} QHostAddress PinPoint::getIP(){return connection.getCentralAddress();}
можете помочь сложить (скелет или же конструктор) для класса анимации
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.Do you like it? Share on social networks!
d
- dsfs
- April 26, 2024, 10:56 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:80points,
- Rating points4
d
- dsfs
- April 26, 2024, 10:35 a.m.
C++ - Test 001. The first program and data types
- Result:73points,
- Rating points1
Last comments
Qt Linux - Lesson 001. Autorun Qt application under Linux как сделать автозапуск для флэтпака, который не даёт создавать файлы в ~/.config - вот это вопрос ))
АК
Qt WinAPI - Lesson 007. Working with ICMP Ping in Qt Без строки #include <QRegularExpressionValidator> в заголовочном файле не работает валидатор.
Анатолий КононенкоFeb. 5, 2024, 7:50 a.m.
EVADec. 25, 2023, 4:30 p.m.
Boost - static linking in CMake project under Windows Сделал всё по-как у вас, но выдаёт ошибку [build] LINK : fatal error LNK1104: не удается открыть файл "libboost_locale-vc142-mt-gd-x64-1_74.lib" Хоть убей, не могу понять в чём дел…
Qt/C++ - Lesson 056. Connecting the Boost library in Qt for MinGW and MSVC compilers Для решения твой проблемы добавь в файл .pro строчку "LIBS += -lws2_32" она решит проблему , лично мне помогло.
Now discuss on the forum
DA
Unlock Your Aesthetic Potential: Explore MSC in Facial Aesthetics and Cosmetology in India Embark on a transformative journey with an msc in facial aesthetics and cosmetology in india . Delve into the intricate world of beauty and rejuvenation, guided by expert faculty and …
Dr Gangil AcademicsApril 20, 2024, 1:45 p.m.
Мобильное приложение на C++Qt и бэкенд к нему на Django Rest Framework Евгений, добрый день! Такой вопрос. Верно ли следующее утверждение: Любое Android-приложение, написанное на Java/Kotlin чисто теоретически (пусть и с большими трудностями) можно написать и на C+…
Павел ДорофеевApril 14, 2024, 8:35 a.m.
Вернуть старое поведение QComboBox, не менять индекс при resetModel Добрый день! У нас много проектов в которых используется QComboBox, в версии 5.5.1, когда модель испускает сигнал resetModel, currentIndex не менялся. В версии 5.15 при resetModel происходит try…