Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Custom control

    General and Desktop
    5
    7
    3074
    Loading More Posts
    • 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
      lloydqt last edited by

      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 Reply Quote 0
      • T
        tucnak last edited by

        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 Reply Quote 0
        • L
          lloydqt last edited by

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

          1 Reply Last reply Reply Quote 0
          • G
            goetz last edited by

            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 Reply Quote 0
            • O
              ObiWan last edited by

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

              1 Reply Last reply Reply Quote 0
              • A
                andre last edited by

                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 Reply Quote 0
                • L
                  lloydqt last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post