QScrollArea isn't auto-scrolling on QRadioButtons



  • I have some widgets inside a QScrollArea:

    scrollArea     = new QScrollArea(&widget);
    groupBoxLayout = new QVBoxLayout();
    groupBox       = new QGroupBox();
    title          = new QLabel();
    
    groupBoxLayout->addWidget(title);
    
    for(int i=0; i<WIDGETS_NUMBER; i++)
    {
        buttons[i] = new QPushButton();
        buttons[i]->setFocusPolicy(Qt::FocusPolicy::StrongFocus);
        buttons[i]->installEventFilter(this);
        groupBoxLayout->addWidget(buttons[i]);
    }
    buttons[0]->setFocus();
    

    Now as long as the buttons[] are QPushButtons, the QScrollArea scrolls automatically on focus change. That is, when I move through the buttons using the Down arrow key, just when I reach the bottom edge of the window, it scrolls down automatically. But just when I change those buttons[] to be QRadioButtons instead, it stops scrolling automatically. Why is that happening? How can I get it to auto-scroll when the focus reaches the edge?

    Of course I can detect a FocusIn event, and manually scroll whenever I need:

    scrollArea->verticalScrollBar()->setValue(scrollArea->verticalScrollBar()->value()+SCROLL_VALUE);
    

    but I want it to be automatic.


Log in to reply
 

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