Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Trigering a repaint event



  • Hi all,I am trying to get a window to be repainted after some set up and I find it weird that it is not being repainted after calling update() .I have even called repaint() on the window and nothing happened.Has anybody run into such a problem before ?If yes I would really appreciate it if you shared.

    Thanks.


  • Moderators

    Are updates enabled (QWidget::setUpdatesEnabled)? Or are we talking about QtQuick? Then you need to set the item dirty (QQuickItem::ItemHasContents) before it will update. See "the doc":http://doc-snapshot.qt-project.org/5.0/qtquick/qquickitem.html#updatePaintNode.



  • I checked that the updates are enabled and they are.I have tried every idea I could come up with and no luck so far.Here is what I want to achieve.I have a bunch of control buttons on my main window and I want to use them to control the position of the palettes(LEFT/RIGHT).

    Here is my slot that responds to a button push:
    @void UBBoardPaletteManager::leftRightButtonClicked()
    {

    UBApplication::boardController->paletteManager()->leftPalette()->setOrientation(eUBDockOrientation_Right);
    UBApplication::boardController->paletteManager()->leftPalette()->repaint();
    UBApplication::mainWindow->repaint();
    UBApplication::app()->processEvents(QEventLoop::AllEvents);
    }@

    and in the constructor of the palette I made sure that updates are enabled by the following code:

    @UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name):
    UBDockPalette(eUBDockPaletteType_LEFT, parent)
    {
    ............

        setUpdatesEnabled(true);
    

    }@

    With this setup it is my belief that after the button is pushed ,the palette(widget) should automatically be redrawn and positioned where i want it to be.

    Is something wrong with my idea flow?Thanks for your time.


Log in to reply