0x436f72647265
0x436f72647265

Reputation: 455

QLabel position not updating

I am creating QLabel objects in my one class, and adding them to my QList<QLabel*> *objects. The QList is created in my main class with the command objects = new QList<QLabel*>(); and then sent to the class where the objects are created and added. This QList is also then sent to my movement class. In my movement class I have a timer that detects if the QList is empty and if it is not, I run through all of the QLabel objects in the QList, and under some circumstances I move the QLabel object.

This is where my problem comes in. The code compiles perfectly and I have used debug and gone through the code, the move commands are executed perfectly and if i use qDebud() to display the x and y coordinate of the QLabel it returns the correct values however the movement is not updated on my display? The QLabel gets deleted perfectly at the correct times and is removed from the screen, but the movements is not shown ?

Is there anyone with some insights into why this will be happening, and how to fix it?

Upvotes: 0

Views: 282

Answers (1)

Alexander V
Alexander V

Reputation: 8698

The code moves widgets and debug output shows position changed but in fact some widgets are still there at previous position. Why?

There is a possibility of some widget position updates being delayed. Try using this call:

QWidget::updateGeometry()

for(auto* pLabel : listOfLabels)
{
   // and other actions suitable
   // pLabel->move(newPoint(x, y));
   pLabel->updateGeometry();
}

Upvotes: 1

Related Questions