Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt QScrollArea autoscroll

Tags:

c++

qt

I'm having problems with QLabel and QScrollArea. I'm trying to make QScrollArea to scroll automatically, but can't find any information about it..

Firstly, I'm using QLabel inside QScrollArea, then QLineEdit outside from QScrollArea. When I type text in QLineEdit, it writes to QLabel and the new line. Whenever it reaches to end of area, QScrollArea doesn't scroll automatically.. How can I do that?

Thank you.

like image 533
Nika Avatar asked Oct 20 '25 11:10

Nika


1 Answers

Can't you use QLineEdit itself instead of Qlabel(if u are using only text)?, so that you dont have to use QScrollArea also.

[edit] What if you set the verticalSlider position to Label->height()

void MainWindow::on_lineEdit_returnPressed() 
{ 
  ui->label->setText(ui->label->text() + ui->lineEdit->text() + "\n"); 

  ui->ScrollArea->verticalScrollBar()->setSliderPosition(label->height())

}
like image 111
Vinod Paul Avatar answered Oct 23 '25 01:10

Vinod Paul