Solved how do i perform autoscroll in QTablewidget ? so it'll scroll down to bottom with a constant speed
-
yea exactly like that, im gonna try that thanks
-
just to make it clear i want the table scroll down as its own just like a movie credit
-
This post is deleted! -
Hi
Fast test
i have
ui->listWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
on.void MainWindow::on_pushButton_released(){ auto timer = new QTimer(this); connect(timer, &QTimer::timeout, this, [this](){ auto bar = ui->listWidget->verticalScrollBar(); bar->setValue( bar->value() + 1 ); }); timer->start(100); }
-
What about https://doc.qt.io/qt-5/qpropertyanimation.html ?
void MainWindow::on_pushButton_released(){ auto anim = new QPropertyAnimation(ui->listWidget->verticalScrollBar(),"value",this); anim ->setDuration(10000); anim->setStartValue(ui->listWidget->verticalScrollBar()->value()); anim->setEndValue(ui->listWidget->verticalScrollBar()->maximum()); connect(anim,&QAbstractAnimation::finished,anim,&QObject::deleteLater); anim->start(); }
-
@VRonin
That actually runs nicer :)
-
@VRonin @mrjj WOW THANKS THATS EXACTLY LIKE I NEEDED THANKS A LOTT!!
oh yea and one more thing i've tried to make it loopin ands make it scroll to the top again by puttin theese lines after the anim->start();
if (tableWidget->verticalScrollBar()->maximum())
{
tableWidget->verticalScrollBar()->setSliderPosition(tableWidget->verticalScrollBar()->minimum());}
but it wont loopin am i wrong to put that there? -
Hi, when the animation stops at the bottom it's deleted, so if you want to loop it, you need to create/new up another one by doing all the steps again:
auto anim = new QPropertyAnimation(ui->listWidget->verticalScrollBar(),"value",this); anim ->setDuration(10000); ... etc etc
-
@hskoglund so i need to to write thoose line again in order to make it loop?
and it will lopp as much as i write it or something like that? -
scroll to the top with animation:
void MainWindow::on_pushButton_released(){ auto anim = new QPropertyAnimation(ui->listWidget->verticalScrollBar(),"value",this); anim ->setDuration(10000); anim->setStartValue(ui->listWidget->verticalScrollBar()->value()); anim->setEndValue(ui->listWidget->verticalScrollBar()->maximum()); bool* once =new bool(true); connect(anim,&QAbstractAnimation::finished,[anim,this,once]()->void{ if(!once) return; *once=false; anim->setStartValue(ui->listWidget->verticalScrollBar()->value()); anim->setEndValue(ui->listWidget->verticalScrollBar()->minimum()); connect(anim,&QAbstractAnimation::finished,anim,&QObject::deleteLater); connect(anim,&QAbstractAnimation::finished,anim,[once](){delete once;}); anim->start(); }); anim->start(); }
Scroll to the top immediately
void MainWindow::on_pushButton_released(){ auto anim = new QPropertyAnimation(ui->listWidget->verticalScrollBar(),"value",this); anim ->setDuration(10000); anim->setStartValue(ui->listWidget->verticalScrollBar()->value()); anim->setEndValue(ui->listWidget->verticalScrollBar()->maximum()); connect(anim,&QAbstractAnimation::finished, ui->listWidget->verticalScrollBar(),std::bind(&QScrollBar::setValue,ui->listWidget->verticalScrollBar(),ui->listWidget->verticalScrollBar()->minimum())); connect(anim,&QAbstractAnimation::finished,anim,&QObject::deleteLater); anim->start(); }
-
@VRonin WOW YOURE A GOD!!! THNX ALOTT!!!