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. [SOLVED] Set Scroll Per Item
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Set Scroll Per Item

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.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.
  • K Offline
    K Offline
    kbt90
    wrote on last edited by
    #1

    Hello -

    I am trying to set the Scroll Mode to Scroll Per Item, as referenced here:

    http://doc.qt.nokia.com/latest/qabstractitemview.html#horizontalScrollMode-prop

    I am using a QScrollArea, and have tried setting the mode as follows:

    @ QScrollArea *scrollArea = new QScrollArea (this);
    scrollAreaWidgetContents->setLayout (appLayout);

    scrollArea->setWidget (scrollAreaWidgetContents);
    scrollArea->setFrameShape (QFrame::NoFrame);
    scrollArea->setAlignment (Qt::AlignCenter);
    scrollArea->setAutoFillBackground (false);
    scrollArea->viewport ()->setAutoFillBackground (false);
    scrollAreaWidgetContents->setAutoFillBackground (false);

    scrollArea->QAbstractItemView::setHorizontalScrollMode (QAbstractItemView::ScrollPerItem);@

    but I get a compiler error that QAbstractItemView is not a base of QScrollArea. I am pretty new to c++ and am unsure what to make of this. I also tried:
    @scrollArea->setHorizontalScrollMode (QAbstractItemView::ScrollPerItem);@
    and get a compiler error that QScrollArea has no member names 'setHorizontalScrollMode'.

    Any help would be much appreciated.
    Thanks,
    Katelyn

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kkrzewniak
      wrote on last edited by
      #2

      The errors say it all. Take a look at the doc page you posted, you will find that QScrollArea does not derive from QAbstractItemView (far from it actually) but it is a derivative of QAbstractScrollArea.

      Me, Grimlock, not "nice dino". ME BASH BRAINS!

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kbt90
        wrote on last edited by
        #3

        So how can I set the scrollArea to scroll per item?

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kkrzewniak
          wrote on last edited by
          #4

          Use a QAbstractItemView sub class. QScrollArea dose not work with items it works with widgets.

          Consider reading a book "C++ GUI Programming with Qt-4 1st edition.":http://www.qtrac.eu/C++-GUI-Programming-with-Qt-4-1st-ed.zip
          Reading a C++ book wouldn't hurt too, ass you are having problems understating simple compiler output.

          Or at least use assistant.

          Me, Grimlock, not "nice dino". ME BASH BRAINS!

          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