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. was setViewportMargins - only at bottom of viewport ? source of "view port " in QT ?
Forum Updated to NodeBB v4.3 + New Features

was setViewportMargins - only at bottom of viewport ? source of "view port " in QT ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 635 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by Anonymous_Banned275
    #1

    EDITED
    Can anybody point me to QT document explaining QT "viewport " and associated "stuff"?
    Especially when it comes to using QTextEdit .
    I found and lost a picture of QTextEdit describing the actual parts of QTextEdit...
    I do not need class doc - it does not contains the info am looking for.
    I am NOT asking for help editing the actual text, I need to learn the terminology QT is using about the "viewpoort".

    For example - as of now it is hit and miss - I can setMaximumHeight(150); of "viewport" but I do not know how to move it....
    Maybe the terminology is not "move Viewport " , maybe in is buried in the QTextEdit class hierarchy...

    It would help me to know how QT manipulates "viewport" - in general terms.
    Thanks

    How do I set setViewportMargins - only at the bottom of viewprort ?

    void setViewportMargins(int left, int top, int right, int bottom);

    The attached code gives this result - margins on left and right of the viewport.
    I need a space / margin of height 10 at the bottom of the viewport only.

    cab14c02-47b8-4601-8c94-e14c8f8b3714-image.png
    '
    setViewportMargins(sz.height()-10,0,sz.height()-10,0);

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Maybe this is the diagram you are thinking of. I do not know of any scroll area specific one.

      The view port is the visible area inside any QAbstractScrollArea that you can see some or all of the internal widget through. If the view port is smaller than the contained widget then you get scroll bars by default. QTextEdit is derived from QAbstractScrollArea and its viewport shows some or all of the render text.

      The view port is whatever size it is, driven entirely by the QAbstractScrollArea-derived widget it is part of. You do not "move it", which is probably why you cannot find it. You can change what portion of the content shows in the viewport with QScrollArea::ensureVisible(). or QScrollArea::scrollContentsBy().

      How do I set setViewportMargins - only at the bottom of viewprort ?

      void setViewportMargins(int left, int top, int right, int bottom);
      

      The attached code gives this result - margins on left and right of the viewport.

      setViewportMargins(sz.height()-10,0,sz.height()-10,0);
      

      Yes. You have set a margin of zero for top and bottom, and non-zero value for left and right, so that is what you got.
      If you want a margin at the bottom then set a number of pixels for that parameter.

      A 1 Reply Last reply
      1
      • C ChrisW67

        Maybe this is the diagram you are thinking of. I do not know of any scroll area specific one.

        The view port is the visible area inside any QAbstractScrollArea that you can see some or all of the internal widget through. If the view port is smaller than the contained widget then you get scroll bars by default. QTextEdit is derived from QAbstractScrollArea and its viewport shows some or all of the render text.

        The view port is whatever size it is, driven entirely by the QAbstractScrollArea-derived widget it is part of. You do not "move it", which is probably why you cannot find it. You can change what portion of the content shows in the viewport with QScrollArea::ensureVisible(). or QScrollArea::scrollContentsBy().

        How do I set setViewportMargins - only at the bottom of viewprort ?

        void setViewportMargins(int left, int top, int right, int bottom);
        

        The attached code gives this result - margins on left and right of the viewport.

        setViewportMargins(sz.height()-10,0,sz.height()-10,0);
        

        Yes. You have set a margin of zero for top and bottom, and non-zero value for left and right, so that is what you got.
        If you want a margin at the bottom then set a number of pixels for that parameter.

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        @ChrisW67 said in was setViewportMargins - only at bottom of viewport ? source of "view port " in QT ?:

        If you want a margin at the bottom then set a number of pixels for that parameter.

        and that is what I was asking for .

        Can you write an actual code for that ?

        It looks as "margin" can be only in pairs - left - right or top = bottom.

        C 1 Reply Last reply
        0
        • A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          I believe my problem is in numbering the points.
          Here is the result of my current code:

          qDebug()<< "\nTRACE_MDI_XTERM sz.height()\n" << QString::number(sz.height());
          qDebug()<< "\nTRACE_MDI_XTERM sz.width() \n" << QString::number(sz.width());
          setViewportMargins(0,0,65,100);

          2f1fb7f0-de49-451a-9347-6a08cce55536-image.png

          and the viewport dimensions

          TRACE_MDI_XTERM sz.height()
          "68"

          TRACE_MDI_XTERM sz.width()
          "102"

          BTW I do appreciate the link, that is not the one I had before.
          And of course - it is missing which way QT aligns x.y coordinates .

          It appears that only upper left corner is for sure x = 0 and y =- 0.

          I think "normal windows " would put y at the bottom right y as minus and x as plus....

          In that case
          i really could use QT coordinates designation / conventions etc.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Anonymous_Banned275
            wrote on last edited by
            #5

            More resources

            https://doc.qt.io/qt-6/coordsys.html

            time for refresher course about "coordinates transform "....

            1 Reply Last reply
            0
            • A Anonymous_Banned275

              @ChrisW67 said in was setViewportMargins - only at bottom of viewport ? source of "view port " in QT ?:

              If you want a margin at the bottom then set a number of pixels for that parameter.

              and that is what I was asking for .

              Can you write an actual code for that ?

              It looks as "margin" can be only in pairs - left - right or top = bottom.

              C Offline
              C Offline
              ChrisW67
              wrote on last edited by ChrisW67
              #6

              @AnneRanch said in was setViewportMargins - only at bottom of viewport ? source of "view port " in QT ?:

              Can you write an actual code for that ?

              Seriously?

              setViewportMargins(0, 0, 0, 10);
              

              i really could use QT coordinates designation / conventions etc.

              Coordinate System

              JonBJ 1 Reply Last reply
              2
              • C ChrisW67

                @AnneRanch said in was setViewportMargins - only at bottom of viewport ? source of "view port " in QT ?:

                Can you write an actual code for that ?

                Seriously?

                setViewportMargins(0, 0, 0, 10);
                

                i really could use QT coordinates designation / conventions etc.

                Coordinate System

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @ChrisW67 Yep! :)

                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