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. QLabel snap to ScrollBar
Qt 6.11 is out! See what's new in the release blog

QLabel snap to ScrollBar

Scheduled Pinned Locked Moved Solved General and Desktop
47 Posts 4 Posters 9.5k 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
    #24

    Thanks so much. It works. Is it possible to split a QLabel on the coordinates 100*100 and add a small button on top of the QLabel ?

    jsulmJ 1 Reply Last reply
    0
    • M Mikeeeeee

      Thanks so much. It works. Is it possible to split a QLabel on the coordinates 100*100 and add a small button on top of the QLabel ?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #25

      @Mikeeeeee said in QLabel snap to ScrollBar:

      split a QLabel

      What does this mean?
      Yes, you can put a button on top of a label.

      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
        #26

        I need to bind the button to a specific area on the image. Please tell me how to do it?

        jsulmJ 1 Reply Last reply
        0
        • M Mikeeeeee

          I need to bind the button to a specific area on the image. Please tell me how to do it?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #27

          @Mikeeeeee Do you actually read documentation?
          https://doc.qt.io/qt-5/qwidget.html#move-1

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

          1 Reply Last reply
          1
          • mrjjM mrjj

            @Mikeeeeee
            Hi
            Its not a signal but a virtual function.
            You have to override it.

            Right clik on the class name
            alt text
            Then select
            alt text
            and you get the function

            protected:
                virtual void wheelEvent(QWheelEvent *event) override
                {
                }
            

            Then do same right click again and select
            alt text

            to move the body of function to the cpp file.

            Now you can try to implement your zoom.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #28

            @mrjj said in QLabel snap to ScrollBar:

            Right clik on the class name

            OMG, this is an option in QtC ?

            I feel so stupid now....


            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
            0
            • M Offline
              M Offline
              Mikeeeeee
              wrote on last edited by Mikeeeeee
              #29

              Do so. But tied to a Qlabel , and not to the Image. Is it possible to link to an Image?

                  QImage mapImage(":/Images/Images/mapMain.png");
                  ImageViewer* myImageViewer  = new ImageViewer();
                  myImageViewer->setImage(mapImage);
                  ui->verticalLayout->addWidget(myImageViewer);
              
                  QPushButton* btn1 = new QPushButton(myImageViewer);
                  btn1->setFixedSize(20,20);
                  btn1->setText("*");
                  btn1->move(20,20);
              
              jsulmJ 1 Reply Last reply
              0
              • M Mikeeeeee

                Do so. But tied to a Qlabel , and not to the Image. Is it possible to link to an Image?

                    QImage mapImage(":/Images/Images/mapMain.png");
                    ImageViewer* myImageViewer  = new ImageViewer();
                    myImageViewer->setImage(mapImage);
                    ui->verticalLayout->addWidget(myImageViewer);
                
                    QPushButton* btn1 = new QPushButton(myImageViewer);
                    btn1->setFixedSize(20,20);
                    btn1->setText("*");
                    btn1->move(20,20);
                
                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #30

                @Mikeeeeee said in QLabel snap to ScrollBar:

                QPushButton* btn1 = new QPushButton(myImageViewer);
                btn1->setFixedSize(20,20);
                btn1->setText("*");
                btn1->move(20,20);

                You forgot

                btn1->show();
                

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

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

                  How do I know the visible coordinates of an Image?

                  jsulmJ 1 Reply Last reply
                  0
                  • M Mikeeeeee

                    How do I know the visible coordinates of an Image?

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #32

                    @Mikeeeeee said in QLabel snap to ScrollBar:

                    How do I know the visible coordinates of an Image?

                    What do you mean?
                    What are "visible coordinates" and relative to what do you want to have them?
                    Do you mean you want to know which part of displayed image is visible?

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

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

                      Yes. For example, I see the Central 50% of the image? How do I know I'm seeing an image from 25% to 75%?

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

                        Partially solve. But regardless of the scrollbar state, pageStep() returns a single value

                        qDebug()<<scrollArea->horizontalScrollBar()->value()
                        <<scrollArea->horizontalScrollBar()->maximum()
                        <<scrollArea->horizontalScrollBar()->minimum()
                        <<scrollArea->horizontalScrollBar()->pageStep();
                        
                        1 Reply Last reply
                        0
                        • mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #35

                          @Mikeeeeee said in QLabel snap to ScrollBar:

                          pageStep

                          But it is a single step value. how much to scroll for a page.
                          What do you need it for ?

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

                            I wanted to know the width of the scroll and scrollbar and calculate the visible part.

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

                              Need to know the size of the scroll and its position and determine.
                              Scroll size = (widget size/picture size)/zoom

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

                                How can I remove the menu bar? If I remove createActions(); from the constructor, the program does not start.

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

                                  Hi
                                  If i do
                                  // createActions();
                                  it starts fine.
                                  Please provide more details.

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

                                    The compiler writes that the program closed abnormally. Debagger says he received a signal from the operating system: SIGSEGV , destination: Segmentation fault

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

                                      If you want, I can send you the project

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

                                        hi
                                        I think its something else than createActions();
                                        Use the debugger to find the line where it crashes.

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

                                          error in qaction.cpp

                                          void QAction::setEnabled(bool b)
                                          {
                                              Q_D(QAction);
                                              if (b == d->enabled && b != d->forceDisabled)
                                                  return;
                                              d->forceDisabled = !b;
                                              if (b && (!d->visible || (d->group && !d->group->isEnabled())))
                                                  return;
                                              QAPP_CHECK("setEnabled");
                                              d->enabled = b;
                                          #ifndef QT_NO_SHORTCUT
                                              d->setShortcutEnabled(b, qApp->d_func()->shortcutMap);  //here
                                          #endif
                                              d->sendDataChanged();
                                          }
                                          
                                          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