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. Scroll Area
Forum Updated to NodeBB v4.3 + New Features

Scroll Area

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 2 Posters 702 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.
  • A Offline
    A Offline
    Alfie Anil
    wrote on last edited by
    #1

    Hello Everyone,
    What I'm trying to do, is when on scroll area is moved, another scroll area moves by the same amount. Is this possible?
    Thanks in advance

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Yes you can do something like

      connect(view1->horizontalScrollBar(), SIGNAL(valueChanged(int)), view2->horizontalScrollBar(), SLOT(setValue(int)));
      connect(view2->horizontalScrollBar(), SIGNAL(valueChanged(int)), view1->horizontalScrollBar(), SLOT(setValue(int)));
      

      https://stackoverflow.com/questions/12304293/synchronize-scrollbar-in-qt

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Alfie Anil
        wrote on last edited by
        #3

        Hi, i've implemented that and I'm sure that will work. But i seem to have a problem when compiling. I have added this in my widget.cpp file and and gives me an error message saying 'No matching member function for call 'connect''.
        Any ideas?
        thanks

        mrjjM 1 Reply Last reply
        0
        • A Alfie Anil

          Hi, i've implemented that and I'm sure that will work. But i seem to have a problem when compiling. I have added this in my widget.cpp file and and gives me an error message saying 'No matching member function for call 'connect''.
          Any ideas?
          thanks

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Alfie-Anil
          HI
          its hard to guess on without the code.
          Could be one of the parameters or that it's not inside a QObject based
          class.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Alfie Anil
            wrote on last edited by
            #5

            Hi this is the code. I've noticed that when I don't use the 'ui->' in a connect it works. however, do have to use it... This is the code:
            ```
            ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
            ui->scrollArea->setWidgetResizable(true);
            ui->scrollArea_2->setWidgetResizable(true);

            QWidget *widget = new QWidget();
            QWidget *newwidget = new QWidget();
            
            ui->scrollArea->setWidget(widget);
            ui->scrollArea_2->setWidget(newwidget);
            QPushButton *button = new QPushButton();
            
            qDebug() << "Initialised widget to scroll area";
            
            connect(ui->scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)), ui->scrollArea_2->verticalScrollBar(), SLOT(setValue(int)));
            
            1 Reply Last reply
            1
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              Hi
              Its one of the sneaky ones.
              you need to add
              #include "QScrollBar"

              in top file file for it to know the type returned by
              ->verticalScrollBar()

              It does give a hit with "incomplete" type
              but still sneaky :)
              alt text

              1 Reply Last reply
              1
              • A Offline
                A Offline
                Alfie Anil
                wrote on last edited by
                #7

                @mrjj
                Thank you. I've now got a new problem that says the program ended unexpectedly, when i set a style sheet for anything in the widget.ui
                Any ideas? Thanks

                mrjjM 1 Reply Last reply
                1
                • A Alfie Anil

                  @mrjj
                  Thank you. I've now got a new problem that says the program ended unexpectedly, when i set a style sheet for anything in the widget.ui
                  Any ideas? Thanks

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Alfie-Anil
                  You right clik in the UI file and use Change stylesheet or what you do ?

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Alfie Anil
                    wrote on last edited by
                    #9

                    I right click on the scroll area that I have added and then click change stylesheet.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Alfie Anil
                      wrote on last edited by Alfie Anil
                      #10

                      I've just got another problem. It says QObject::connect: No such signal QObject::valueChanged(int)

                      anyideas?

                      connect(ui->scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)), ui->scrollArea_2->verticalScrollBar(), SLOT(setValue(int)));
                      
                      1 Reply Last reply
                      0
                      • mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Hi
                        It compiles for me.
                        Try to do a build -> clean and
                        rebuild all.

                        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