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. QGraphcisView with QOpenGlWidget not updating properly on resize and scroll
Forum Updated to NodeBB v4.3 + New Features

QGraphcisView with QOpenGlWidget not updating properly on resize and scroll

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 4 Posters 1.0k 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.
  • SGaistS SGaist

    Hi,

    Out of curiosity, why do you have your QGraphicsView inside a QScrollArea ?

    H Offline
    H Offline
    Hristo Konstantinov
    wrote on last edited by Hristo Konstantinov
    #6

    @SGaist My custom QWidget(which contains the graphic view) is inside of the QScrollArea, since it has dynamic changes in height, and usually is bigger then the monitor itself, so I need to scroll it's contents some how:

    alt text
    alt text

    If there is any better way, which lets me get around the problem, I am open to suggestions

    eyllanescE 1 Reply Last reply
    0
    • H Offline
      H Offline
      Hristo Konstantinov
      wrote on last edited by Hristo Konstantinov
      #7

      Okay guys, just tell me which function to call, to repaint the viewport of the QGraphicsView properly, by myself. I'll override every resize and every scroll event and call it there if I have to.

      1 Reply Last reply
      0
      • H Hristo Konstantinov

        @SGaist My custom QWidget(which contains the graphic view) is inside of the QScrollArea, since it has dynamic changes in height, and usually is bigger then the monitor itself, so I need to scroll it's contents some how:

        alt text
        alt text

        If there is any better way, which lets me get around the problem, I am open to suggestions

        eyllanescE Offline
        eyllanescE Offline
        eyllanesc
        wrote on last edited by
        #8

        @Hristo-Konstantinov What @SGaist points out is that it is unnecessary to place a QGraphicsView in a QScrollArea since they both inherit from QAbstractScrollArea so if the content is very large then scrollbars will appear

        If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

        H 1 Reply Last reply
        1
        • eyllanescE eyllanesc

          @Hristo-Konstantinov What @SGaist points out is that it is unnecessary to place a QGraphicsView in a QScrollArea since they both inherit from QAbstractScrollArea so if the content is very large then scrollbars will appear

          H Offline
          H Offline
          Hristo Konstantinov
          wrote on last edited by
          #9

          @eyllanesc QGraphicsView has a fixed size. It is a child of the custom widget, which is very large. So I need QScrollArea not for the graphicsview, but for the widget, which holds the graphicsview

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #10

            Hum... that sounds like a bug lurking...

            You wrote that you have that issue when resizing programmatically, can you show how you do that ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Hristo Konstantinov
              wrote on last edited by Hristo Konstantinov
              #11
              ScrollPos TabView::getScrollPos()
              {
                  return ScrollPos
                  {
                      ui.scrollArea->verticalScrollBar()->value(),
                      ui.scrollArea->horizontalScrollBar()->value()
                  };
              }
              
              void TabView::setScrollPos(ScrollPos scrollPos)
              {
                  ui.scrollArea->verticalScrollBar()->setValue(scrollPos.height);
                  ui.scrollArea->horizontalScrollBar()->setValue(scrollPos.width);
              }
              

              I'm saving the scroll position in a vector of custom structs each time new tab is selected, and when I select the older tab, the presenter calls setScrollPos with the ScrollPos struct as an argument. Nothing fancy. But even if I resize the application window from the ui, if the graphicsview goes out of the viewport of the QScrollArea, the graphicitems in it that are hidden "outside" of the app window, don't draw themselves automatically when shown again, unless I hover them with the mouse. Now the question is how the mouse triggers their repainting and makes them appear again? If I know what does mouse hovering does on QGraphicsView to initialize the QOpenGl viewport repaint, I can call this function when I have to.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #12

                Just to be sure I understand your architecture:

                • you have a QTabBar
                • on top of a QScrollArea
                • inside of which you have a complex widget containing a QGraphicsView beside other widgets

                Is that correct ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                H 1 Reply Last reply
                0
                • SGaistS SGaist

                  Just to be sure I understand your architecture:

                  • you have a QTabBar
                  • on top of a QScrollArea
                  • inside of which you have a complex widget containing a QGraphicsView beside other widgets

                  Is that correct ?

                  H Offline
                  H Offline
                  Hristo Konstantinov
                  wrote on last edited by Hristo Konstantinov
                  #13

                  @SGaist Exactly. I don't want to use QTabWidget, because it creates a new Widget everytime a new tab is "opened", and my widget, which contains the graphicsview is heavy, so I just emulate that behavior. The view itself is always the same, placed inside the QScrollArea. The selected tab just sends signal to the presenter (I keep my business and QT logic separated via MVP), and that signal contains the index of the data (which is stored for each tab in a vector) and then the data is displayed on the widget, which is inside of the QScrollArea.

                  jsulmJ 1 Reply Last reply
                  0
                  • H Hristo Konstantinov

                    @SGaist Exactly. I don't want to use QTabWidget, because it creates a new Widget everytime a new tab is "opened", and my widget, which contains the graphicsview is heavy, so I just emulate that behavior. The view itself is always the same, placed inside the QScrollArea. The selected tab just sends signal to the presenter (I keep my business and QT logic separated via MVP), and that signal contains the index of the data (which is stored for each tab in a vector) and then the data is displayed on the widget, which is inside of the QScrollArea.

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

                    @Hristo-Konstantinov said in QGraphcisView with QOpenGlWidget not updating properly on resize and scroll:

                    I don't want to use QTabWidget, because it creates a new Widget everytime a new tab is "opened"

                    No, it does not create a widget every time a tab is selected, it shows the widget which was put on that tab.

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

                    H 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @Hristo-Konstantinov said in QGraphcisView with QOpenGlWidget not updating properly on resize and scroll:

                      I don't want to use QTabWidget, because it creates a new Widget everytime a new tab is "opened"

                      No, it does not create a widget every time a tab is selected, it shows the widget which was put on that tab.

                      H Offline
                      H Offline
                      Hristo Konstantinov
                      wrote on last edited by Hristo Konstantinov
                      #15

                      @jsulm oh, you're right. So maybe the real reason was I had to take back ownership of the widget every time the tab was closed, so it wouldn't get destroyed. Have been writing this app ever since I started learning programming an year ago, and I can't remember all of my decisions, sorry.

                      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