[Unsolved] QWidget won't Scroll (Qt 4 & 5)
-
Hi everyone! I'm trying to make some messages to scroll. I'm using a QLabel for the message inside a QScrollArea.
I also used a timer to make it scroll every few ms. The problem is that for some reason it only works on a very specific method of the class that makes it all.What I tried to do is to scroll the message to the right far end of the screen in order to make it move to the left like a marquee. But It just ignores the
@QWidget->scroll(int dx, int dy)
@
method.This is the relevant code of my class:
@
#include "boardwindow.h"
#include "ui_boardwindow.h"BoardWindow::BoardWindow(QWidget *parent) : QWidget(parent), ui(new Ui::BoardWindow)
{
ui->setupUi(this);
Scroller= new QTimer(this);
//connect(Scroller, SIGNAL(timeout()), this, SLOT(ScrollText()));
}BoardWindow::~BoardWindow()
{
delete ui;
}void BoardWindow::Initialize()
{
QDesktopWidget test;// Ventana sin borde ni botones. Y por encima de cualquier otra setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); // En que resolucion estamos? DesktopRes= test.availableGeometry(test.primaryScreen()); // Adaptemos la ventana para la resolucion actual! resize(DesktopRes.width(), height()); // Finalmente, vamos a mover la ventana al borde inferior del monitor move(0, DesktopRes.height()-40); NextMessage(); Scroller->start(50);
}
// Esta es la funcion que animara el texto
void BoardWindow::ScrollText()
{
/* MessagePosition= ui->ScrollingText->pos();// Ya salio de pantalla? if (MessagePosition.x()<=-ui->ScrollingText->width()) NextMessage(); else ui->ScrollAreaWidget->scroll(-5, 0);
*/
}/* Esta funcion cargara un nuevo texo de Messages cuando
- el anterior haya salido totalmente de la pantalla
/
void BoardWindow::NextMessage()
{
ui->ScrollAreaWidget->scroll(500, 0);
qDebug("AHORA EN: %d", ui->ScrollingText->pos().x());
/ qDebug("next");
ui->ScrollingText->setText("Ola ke ase");
ui->ScrollAreaWidget->scroll(DesktopRes.width(), 0);*/
}
@
It doesn't work anywhere else but on ScrollText()
Does anyone knows why? I've read the QWidget reference for scroll(int dx, int dy) and I haven't seen any precondition or anything that prevents it to work.
- el anterior haya salido totalmente de la pantalla