PQColorAnimation работает только с объектами типа QColor и моделью цвета RGB.

Для управления альфа-прозрачностью цвета следует использовать QPropertyAnimation, передав в качестве целевого объекта объект QColor. Допускается применение нескольких разнотипных анимаций для одного и того-же объекта QColor.

on*-свойства

onCurrentLoopChanged( object $sender, int $currentLoop )
onDirectionChanged( object $sender, int $newDirection )
onFinished( object $sender )
onStateChanged( object $sender, int $newState, int $oldState )
onValueChanged( object $sender, string $color )

Свойства

QColortargetColor READ / WRITE

Методы

PQColorAnimation__construct ( )
PQColorAnimation__construct ( QColor $target )
PQColorAnimation__construct ( QColor $target, QObject $parent )
QColortargetColor ( )

Слоты

boolsetEndValue ( string $color )
boolsetStartValue ( string $color )
voidsetTargetColor ( QColor $target )

Сигналы

voidcurrentLoopChanged ( int $currentLoop )
voiddirectionChanged ( int $newDirection )
voidfinished ( )
voidstateChanged ( int $newState, int $oldState )
voidvalueChanged ( string $color )

Описание методов

PQColorAnimation PQColorAnimation::__construct ( )  

Создаёт объект PQColorAnimation.

PQColorAnimation PQColorAnimation::__construct ( QColor $target )  

Создаёт объект PQColorAnimation и устанавливает целевой объект $target с типом QColor для анимирования. Продолжительность анимации по умолчанию устанавливается равной 250 мс.

PQColorAnimation PQColorAnimation::__construct ( QColor $target, QObject $parent )  

Создаёт объект PQColorAnimation с родительским объектом $parent и устанавливает целевой объект $target с типом QColor для анимирования. Продолжительность анимации по умолчанию устанавливается равной 250 мс.

QColor PQColorAnimation::targetColor ( )  

Возвращает назначенный анимируемый объект QColor.

Описание слотов

bool PQColorAnimation::setEndValue ( string $color )  

Устанавливает завершающее значение цвета для анимируемого объекта в формате #RRGGBB

bool PQColorAnimation::setStartValue ( string $color )  

Устанавливает начальное значение цвета для анимируемого объекта в формате #RRGGBB

void PQColorAnimation::setTargetColor ( QColor $target )  

Устанавливает анимируемый объект типа QColor.

Описание сигналов

void PQColorAnimation::currentLoopChanged ( int $currentLoop )  

PQColorAnimation отправляет этот сигнал каждый раз, когда текущий цикл изменяется. $currentLoop - это номер текущего цикла.

void PQColorAnimation::directionChanged ( int $newDirection )  

PQColorAnimation отправляет этот сигнал каждый раз при изменении направления. $newDirection - это новое значение направления.

void PQColorAnimation::finished ( )  

PQColorAnimation отправляет этот сигнал после завершения анимации.

void PQColorAnimation::stateChanged ( int $newState, int $oldState )  

PQColorAnimation отправляет этот сигнал каждый раз, когда состояние анимации изменились из $oldState в $newState. Сигнал отправляется после вызова функции updateState().

void PQColorAnimation::valueChanged ( string $color )  

Примеры

// Создаем основное окно
class MainWindow extends QWidget {
    private $animation;
    private $color;
    
    private $colors; // массив сгенерированных цветов

    public function __construct() {
        parent::__construct();
        
        $this->colors = [];
        $this->color = new QColor;
        
        // создаем анимацию, передав ей целевой цвет,
        // установив длительность равной 10 сек,
        // и указав начальное и конечно значение цвета
        $this->animation = new PQColorAnimation($this->color);
        $this->animation->setDuration(10000);
        $this->animation->setStartValue("#ff0000");
        $this->animation->setEndValue("#0000ff");
        
        // связываем сигнал смены значения цвета 
        // с анонимной функцией, обрабатывающей обновленное значение,
        // где $value - это обновленное значение цвета
        $this->animation->onValueChanged = function($self, $value) {
            $this->windowTitle = "Background color: $value";
            $this->styleSheet = "background-color: $value;";
            $this->colors[] = $value;
        };
        
        // по завершении анимации выводим список сгенерированных цветов
        $this->animation->onFinished = function() {
            pre($this->colors);
        };
        
        $this->animation->start();
    }
}

$mainWindow = new MainWindow;
$mainWindow->show();

qApp::exec();����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
comments powered by HyperComments