ScrollBar



  • I am not able to get a Scroll bar. I declared the QAbstractScrollBarPolicy in main.cpp and worked the commands given below
    QAbstractScrollArea::setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

    QAbstractScrollArea::setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    

    getting the following error
    main.cpp:18: error: cannot call member function 'void QAbstractScrollArea::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy)' without object


  • Moderators

    This method is not intended for setting the scroll bar policy globally. You need to have a valid object and set it on that object.



  • Can you elaborate, I am not getting it.


  • Moderators

    If you have a, say, QGraphicsView in your application, you can use this method like this:
    @
    QGraphicsView *myView = new QGraphicsView(this);
    myView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    @

    You cannot, however, call this method without object, it is not static:
    @
    // will not work!
    QAbstractScrollArea::setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    @



  • Thanks. I'll try that


Log in to reply
 

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