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. Custom control
QtWS25 Last Chance

Custom control

Scheduled Pinned Locked Moved General and Desktop
7 Posts 5 Posters 3.6k Views
  • 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.
  • L Offline
    L Offline
    lloydqt
    wrote on last edited by
    #1

    Hi,

    I want to write a custom control (something like a hexviewer). It has a very large client area, so it needs scroll bars. so derived a class from QScrollArea and called the SetWidget method. The following are my doubts...

    1. how can I set the size of client area (for drawing) ? is it by using resize() call? When I call resize, the whole window gets resized, how can I make it show the scrollbars?

    2. is it possible to set the width and height of client area in 64bits (long long) than in 32bits?

    Thanks,
    Lloyd

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tucnak
      wrote on last edited by
      #2

      AFAIN, in QAbsractScrollArea you can draw on widget without any restrictions. It will automatic create scroll bars.

      1. With QWidget::setSize(QSise&)
      2. No. QWidget use int.
      1 Reply Last reply
      0
      • L Offline
        L Offline
        lloydqt
        wrote on last edited by
        #3

        I too have been searching for the method QWidget::setSize(). But, unfortunately could not find any!! Am i wrong?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          You call setWidget() with some other widget. You need to resize that one, not the scroll area widget. For example:

          @
          QScrollArea *area = new QScrollArea;
          QLabel *clientWidget = new QLabel(area);
          area->setWidget(clientWidget);

          // ... later on

          clientWidget->resize(1000,5000);
          @

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • O Offline
            O Offline
            ObiWan
            wrote on last edited by
            #5

            If your client widget has a layout, fill your layout with your widgets and call:
            @
            clientWidget->setMinimumSize(clientWidgetLayout->sizeHint());
            @

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              If you have a huge client area, like you may have for a hex viewer, I recommend against using a separate widget as the viewer inside a QScrollArea. This solution is very nice for forms that extend beyond the screen size on small screens of something like that, but not for potentially huge views.

              Take a hint from how the Qt item view classes are implemented instead. They derive from QAbstractScrollArea, and take care of the rendering of the client area themselves. That is really the only way to go without getting into immediate problems with coordinate systems. Note that the actual width and height of your widgets may, depending on the underlying system, be actually much more constrained than the 32 bits limit you see. Think 16 bits unsigned... That is not a Qt limitation, but a limitation of the underlying system in that case. You circumvent this issue if you don't try to put a huge viewing widget inside a QScrollArea, but do your own rendering instead.

              If you then also take the position of the scrollBar as indicating the actual row, rather than the top pixel row, you can display 2^31 rows of items (note that the scrolbar uses an integer for its position, not an unsigned integer). If that is not enough, than you really need to think of a different way of navigating your content, as a scrollbar is not going to help the user anymore long before you reach that limit. Every pixel of the scrollbar on the screen (using the full screen height, even on the new Retina MacBooks!) is going to represent more than a million lines of data in your view.

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lloydqt
                wrote on last edited by
                #7

                Thanks a lot. I was looking for an elegant solution like this.

                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