Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get QScrollerProperties from Qscrollbar class?
Forum Updated to NodeBB v4.3 + New Features

How to get QScrollerProperties from Qscrollbar class?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 338 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IknowQT
    wrote on last edited by
    #1

    There is a user class that inherits QScrollbar class.
    I wanted to put the same scroll attribute everywhere I use this class.
    So I tried to give the scroll property when initializing the class, but it failed.

    I've tried using QScrollerProperties. That was the scroller class. I don't think the scrollbar class or the scroller class is different.

    Please tell me how to use the QScrollerProperties property in the scrollbar class.

    void usrScrollBar::InitScrollProp()
    {
    	QScroller* scroller = QScroller::scroller(this);
    	QScrollerProperties properties = QScroller::scroller(scroller)->scrollerProperties();
    
    	QVariant overshootPolicy = QVariant::fromValue<QScrollerProperties::OvershootPolicy>(QScrollerProperties::OvershootAlwaysOff);
    	{
    		properties.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, overshootPolicy);
    		scroller->setScrollerProperties(properties);
    
    		properties.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, overshootPolicy);
    		scroller->setScrollerProperties(properties);
    	}
    }
    
    Christian EhrlicherC C 2 Replies Last reply
    0
    • I IknowQT

      There is a user class that inherits QScrollbar class.
      I wanted to put the same scroll attribute everywhere I use this class.
      So I tried to give the scroll property when initializing the class, but it failed.

      I've tried using QScrollerProperties. That was the scroller class. I don't think the scrollbar class or the scroller class is different.

      Please tell me how to use the QScrollerProperties property in the scrollbar class.

      void usrScrollBar::InitScrollProp()
      {
      	QScroller* scroller = QScroller::scroller(this);
      	QScrollerProperties properties = QScroller::scroller(scroller)->scrollerProperties();
      
      	QVariant overshootPolicy = QVariant::fromValue<QScrollerProperties::OvershootPolicy>(QScrollerProperties::OvershootAlwaysOff);
      	{
      		properties.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, overshootPolicy);
      		scroller->setScrollerProperties(properties);
      
      		properties.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, overshootPolicy);
      		scroller->setScrollerProperties(properties);
      	}
      }
      
      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @IknowQT said in How to get QScrollerProperties from Qscrollbar class?:

      but it failed.

      This is no error description...

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      I 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @IknowQT said in How to get QScrollerProperties from Qscrollbar class?:

        but it failed.

        This is no error description...

        I Offline
        I Offline
        IknowQT
        wrote on last edited by
        #3

        @Christian-Ehrlicher

        The build was successful. Overshooting is still working.

        1 Reply Last reply
        0
        • I IknowQT

          There is a user class that inherits QScrollbar class.
          I wanted to put the same scroll attribute everywhere I use this class.
          So I tried to give the scroll property when initializing the class, but it failed.

          I've tried using QScrollerProperties. That was the scroller class. I don't think the scrollbar class or the scroller class is different.

          Please tell me how to use the QScrollerProperties property in the scrollbar class.

          void usrScrollBar::InitScrollProp()
          {
          	QScroller* scroller = QScroller::scroller(this);
          	QScrollerProperties properties = QScroller::scroller(scroller)->scrollerProperties();
          
          	QVariant overshootPolicy = QVariant::fromValue<QScrollerProperties::OvershootPolicy>(QScrollerProperties::OvershootAlwaysOff);
          	{
          		properties.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, overshootPolicy);
          		scroller->setScrollerProperties(properties);
          
          		properties.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, overshootPolicy);
          		scroller->setScrollerProperties(properties);
          	}
          }
          
          C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          @IknowQT

          You gather the scroller associated with the QScrollbar

          	QScroller* scroller = QScroller::scroller(this);
          

          then

          	QScrollerProperties properties = QScroller::scroller(scroller)->scrollerProperties();
          

          you gather/create a QScroller associated with the first QScroller.

          Did you mean this perhaps?

          	QScroller* scroller = QScroller::scroller(this);
          	QScrollerProperties properties = scroller->scrollerProperties();
          
          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved