Styling of Scroll Bars in QscrollArea



  • Hi I have the following code in which a pointer variable of QScrollArea has been assigned widgets in a loop.

    Now I want to style horizontal scroll bars as they are white and transparent when I use them to scroll.

    I have made the following changings to set 'off' the scroll bar for confirmation but nothing is happening.

    I think i am not utilizing the the QScrollArea variable "pSArea" correctly.

    CODE:

    QScrollArea* pSArea = (QScrollArea*)widget(i);
    ShaderEditor* sEditor = (ShaderEditor*)pSArea->widget();
    pSArea->setBackgroundRole(QPalette::Dark);
    pSArea->setAutoFillBackground(true);
    pSArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);


  • Qt Champions 2017

    Hi
    Try
    QScrollArea* pSArea = qobject_cast <QScrollArea*> ( widget(i) );
    if( pSArea ) {
    pSArea->setBackgroundRole(QPalette::Dark);
    pSArea->setAutoFillBackground(true);
    pSArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    } else
    qDebug() << "cast failed";


Log in to reply
 

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