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. How to enable resizing of a frameless widget
QtWS25 Last Chance

How to enable resizing of a frameless widget

Scheduled Pinned Locked Moved General and Desktop
16 Posts 3 Posters 20.0k 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.
  • A Offline
    A Offline
    andre
    wrote on last edited by
    #4

    Is this the same issue as the one you're discussing in "this":/forums/viewthread/16161/ topic?

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

      Perhaps, yes. As no one replied to my my query yesterday, I figured out a way myself, but got stuck with other problem. So, i asked this question to completely change the way of resizing. The code is same, but i want to use resizing event as it enables resizing from every side and Qsizegrip allows resizing only from one corner

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

        I hope you are not angry

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

          You need to practice more patience. Please recognize that it is Easter weekend, and lots of people are enjoying time off with their families. At least have patience until, say Wednessday before you start thinking that your topic is being ignored. It is not good practice to open multiple parallel topics that are really about the same thing in any case.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            adnan
            wrote on last edited by
            #8

            I am sorry, perhaps I should have closed the previous topic , i will be doing now, btw what about resizing?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dbzhang800
              wrote on last edited by
              #9

              [quote author="adnan" date="1333967014"]What to write here:
              @void CropFrame::resizeEvent(QResizeEvent *event)
              {
              //what to write here
              }@[/quote]

              You need to call resize() or setGeometry() to change the size of your widget.

              resizeEvent() doesn't do such things, this is similer to mousePressEvent() which is called when you press your mouse, but it doesn't press mouse by itself.

              you can call resize() when your mouse pressed --> moved --> released.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                adnan
                wrote on last edited by
                #10

                If we consider any normal widget, just by moving the mouse to the boundary changes the shape of cursor, and we can resize that widget, can't we just restore the same resizing ability with same features of cursor shape change etc. in frameless widgets.
                Besides, i am using mousepressevent for draging
                @void CropFrame::mousePressEvent(QMouseEvent *event)
                {
                if (event->button() == Qt::LeftButton) {
                dragPosition = event->globalPos() - frameGeometry().topLeft();
                event->accept();
                }
                }@

                How will it know, whether it has to resize or drag if i use resize() in mousepressevent

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dbzhang800
                  wrote on last edited by
                  #11

                  [quote author="adnan" date="1333996860"]
                  How will it know, whether it has to resize or drag if i use resize() in mousepressevent[/quote]

                  It depends on you.

                  For example, when you move the mouse to the boundary(close to the boundary but still in your widget),
                  which behavior is you wanted. Changes the shape of cursor or not?

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    adnan
                    wrote on last edited by
                    #12

                    Alright, i don't wish to lenghten this discussion: QSizeGrip is working fine but has one issue, if you can resolve the issue the story ends here, no need of resizing using resizing event. I don't have much experience in event handling.

                    Actually the above Qlabel variant that is CropFrame class, I am using to mark the region for cropping. It is actually for selecting the area for cropping. For cropping i am passing the top left co-ordinates and height and width of CropFrame object. In mousemoveEvent i am storing the top left co-ordinates in @ topPos=event->globalPos() - dragPosition;@
                    @void CropFrame::mouseMoveEvent(QMouseEvent *event)
                    {
                    if (event->buttons() & Qt::LeftButton) {
                    move(event->globalPos() - dragPosition);
                    topPos=event->globalPos() - dragPosition;
                    event->accept();
                    }
                    }@
                    Now suppose i move the cropping rectangle in the middle, topPos is updated as expected, but now if i resize by holding QSizeGrip without moving the crop-rectantgle and increase the dimensions of rectangle, lenght and width are updated but topPos is not updated thereby causing problem. If somehow QSizeGrip appears at bottom right then everything wud be fine as it wud only increase length and width without changing topPos.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      adnan
                      wrote on last edited by
                      #13

                      Anybody plz help! I have to submit my project within 3 days. I don't want to submit my project with above bug.

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        dbzhang800
                        wrote on last edited by
                        #14

                        [quote author="adnan" date="1334000971"]Anybody plz help! I have to submit my project within 3 days. I don't want to submit my project with above bug.[/quote]

                        Please note that, QLabel is a QWidget, QGripSize is another QWidget.
                        one widget can be put any where in another widget.

                        In your code, you forget to specify the location of QGripSize.

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          adnan
                          wrote on last edited by
                          #15

                          How to specify the the location. I couldn't find any function. There is hardly a one page doc for QsizeGrip in Qt docs

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

                            You could use a layout, or you reimplement the resizeEvent of your widget to manually position the size grip.

                            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