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 connect slot to QScrollBar::rangeChanged signal?
Forum Updated to NodeBB v4.3 + New Features

How to connect slot to QScrollBar::rangeChanged signal?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 1.1k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    Hi!
    I using Image Viewer Example
    How to connect slot to QScrollBar::rangeChanged signal?
    It's not work:

    connect(scrollArea, &QScrollBar::rangeChanged, this, &ImageViewer::updateSize);
    
    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • M Mikeeeeee

      Hi!
      I using Image Viewer Example
      How to connect slot to QScrollBar::rangeChanged signal?
      It's not work:

      connect(scrollArea, &QScrollBar::rangeChanged, this, &ImageViewer::updateSize);
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @Mikeeeeee said in How to connect slot to QScrollBar::rangeChanged signal?:

      It's not work:

      Why don't you say what happens?
      Do you expect others to guess?
      How does ImageViewer::updateSize signature look like?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #3

        I want to get the QScrollBar status change signal and then I want to get different sizes of QScrollBar.

        void ImageViewer::updateSize()
        {
        
           /* qDebug()<<scrollArea->horizontalScrollBar()->value()
                   <<scrollArea->horizontalScrollBar()->maximum()
                     //<<scrollArea->horizontalScrollBar()->sliderPosition() //тоже, что и value
                  <<scrollArea->horizontalScrollBar()->minimum()
                 <<scrollArea->horizontalScrollBar()->pageStep();*/
        }
        
        jsulmJ 1 Reply Last reply
        0
        • M Mikeeeeee

          Hi!
          I using Image Viewer Example
          How to connect slot to QScrollBar::rangeChanged signal?
          It's not work:

          connect(scrollArea, &QScrollBar::rangeChanged, this, &ImageViewer::updateSize);
          
          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @Mikeeeeee
          you should post your error message,

          from the naming of things, my guess is, scrollArea is a QScrollArea not a QScrollBar


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          2
          • M Mikeeeeee

            I want to get the QScrollBar status change signal and then I want to get different sizes of QScrollBar.

            void ImageViewer::updateSize()
            {
            
               /* qDebug()<<scrollArea->horizontalScrollBar()->value()
                       <<scrollArea->horizontalScrollBar()->maximum()
                         //<<scrollArea->horizontalScrollBar()->sliderPosition() //тоже, что и value
                      <<scrollArea->horizontalScrollBar()->minimum()
                     <<scrollArea->horizontalScrollBar()->pageStep();*/
            }
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by jsulm
            #5

            @Mikeeeeee You are aware that rangeChanged has two parameters?
            Also, you still don't want to tell us what is exactly the problem?! Error message?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • M Offline
              M Offline
              Mikeeeeee
              wrote on last edited by
              #6
              QScrollArea *scrollArea;
              

              if i do this:

              connect(scrollArea, &QScrollBar::rangeChanged, this, &ImageViewer::updateSize);
              

              I get error: no matching member function for call to 'connect'
              As with any change QScrollArea *scrollArea tun ImageViewer::updateSize()?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Mikeeeeee
                wrote on last edited by Mikeeeeee
                #7

                Maybe I can use QWidget::changeEvent(QEvent * event)?
                But this too not work:

                void updateSize(QEvent * event);
                
                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi
                  You are not using correct parameters.
                  its
                  rangeChanged(int min, int max)
                  so your slot should also have those.

                  void ImageViewer::updateSize( int min, int max )
                  {
                  ...
                  and you say
                  connect(scrollArea, &QScrollBar::rangeChanged, this, &ImageViewer::updateSize);
                  but its not scrollArea that has rangeChanged, its its scrollbar
                  so it should be
                  connect(scrollArea->verticalScrollBar(), &QScrollBar::rangeChanged, this, &ImageViewer::updateSize);
                  and thats for the vertical scrollbar, thre is also a horizontal.

                  1 Reply Last reply
                  2

                  • Login

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