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. Moving selection from QPushButton to top object in QScrollArea does not move the view to the selected object.

Moving selection from QPushButton to top object in QScrollArea does not move the view to the selected object.

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 882 Views 2 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
    Marne
    wrote on last edited by
    #1

    I have set up a ScrollArea, with options spaced, expanding vertically. At the bottom there is a button. When there is enough options to cause the window to be scrollable, tabbing to select objects going from the button to the top object in the scrollArea, does not move the visible view to show the selected object, it only moves if the tabbing is done between objects in the scrollArea.

    Here is a dummy code for how it is setup.

      Dummy_func(qt::QtAreaInfo* area, QWidget* parent)
        : QWidget(parent)
        , _area(area) {
      setFocusPolicy(Qt::NoFocus);
    
      auto layout = new QVBoxLayout;
      setLayout(layout);
    
      _wid= new QWidget;
      _wid->setContentsMargins({});
      _wid->setFocusPolicy(Qt::NoFocus);
      _wid->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
    
      _widLayout = new QVBoxLayout;
      _widLayout->setContentsMargins({});
      _wid->setLayout(_widLayout);
    
      _widLayout = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
      _filterAreaLayout->addSpacerItem(_widAreaStretch);
    
      auto scrollArea = new QScrollArea();
      scrollArea->setContentsMargins({});
      scrollArea->setWidget(_wid);
      scrollArea->setWidgetResizable(true);
      scrollArea->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
      scrollArea->setFrameShape(QFrame::NoFrame);
      scrollArea->setFocusPolicy(Qt::NoFocus);
    
      scrollArea->setVerticalScrollBar(new FramedScrollBar(scrollArea));
    
      layout->addWidget(scrollArea);
      scrollArea->verticalScrollBar()->installEventFilter(this);
      layout->addStretch();
    
      auto buttonLayout = new QHBoxLayout;
      buttonLayout->addStretch();
      layout->addLayout(buttonLayout);
    
      auto but = new QPushButton("test");
      buttonLayout->addWidget(but);
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Which version of Qt ?
      On which OS ?
      Also please provide a complete, minimal, buildable example. Your code as is, cannot be built.

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

      M 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Which version of Qt ?
        On which OS ?
        Also please provide a complete, minimal, buildable example. Your code as is, cannot be built.

        M Offline
        M Offline
        Marne
        wrote on last edited by
        #3

        pastebin link as I got denied akismet for spam

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Marne
          wrote on last edited by
          #4

          @SGaist Hello!

          Does it work with the pastebin link? I am still not able to post code here directly, getting blocked as a spammer.

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

            Hi,

            Sorry for the late reply. Yes it's all good. One thing I didn't notice originally. You are disabling focus policies on all your widgets so how do you expect keyboard navigation to function ?

            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
            • M Offline
              M Offline
              Marne
              wrote on last edited by
              #6

              I have been testing around with setting tabFocus on the different widgets with different configurations, but with no difference in outcome. In the example provided keyboard navigation does work, it just does not focus when going from the button to the top item. Perhaps I am using the focus policies wrong, but I could not set it in a way that allowed the desired behaviour.

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

                @SGaist
                Hello, have you had a chance to look at my last message?

                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