Setting Focus on Button and let verticalScrollbar to Top does not work



  • Hi all,

    I have a StackedWidget containing a Scrollbar with some labels and Buttons in it.
    The labels are placed at the top and the buttons below.

    In the constructor I set the focus to the button (preselected) scrollbar moves a bit down (so far its okay)

    But I wanted to have the scrollbar at top at startup so I thought I just set the Scrollbar to 0

    @
    ui->pushButtonDefault->setFocus();
    ui->scrollArea->verticalScrollBar()->setValue( 0 ); //scroll to top
    @

    But the scrollbar does not move to the top if the button setFocus is called before, this only works if I do not set the Focus to the Button or let a Timer timeout slot call the scrollbar function after some seconds.

    Does anyone have an idea why this happens? Is it not allowed to set these in this combination?

    Many Thanks



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.