Results 1 to 7 of 7

Thread: Giving user facility to resize widgets run time

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Giving user facility to resize widgets run time

    Ok. I tried doing the following.

    For 1) I tried reimplementing the resizeEvent() of the iwdget. But for some reason my resizeEvent() is not being called. Does anybody have any idea when the resizeEvent() of any widget will be called?

    For 2) I tried reimplementing the mousePressEvent and the mouseMoveEvent. In the first one I stored the position of the mouse Press and then int he second one I detected the mouse move event position and simply called the move(new_position - old_position) to move the widget. It works to some extent, the widget does move but not so smoothly there's some problem, it sometimes goes to the top left corner. It just doesn't work correctly some of the times.

    Does anybody have any idea about these?

    Charvi.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Giving user facility to resize widgets run time

    Quote Originally Posted by Charvi View Post
    For 1) I tried reimplementing the resizeEvent() of the iwdget. But for some reason my resizeEvent() is not being called. Does anybody have any idea when the resizeEvent() of any widget will be called?
    When the widget is resized.

    For 2) I tried reimplementing the mousePressEvent and the mouseMoveEvent. In the first one I stored the position of the mouse Press and then int he second one I detected the mouse move event position and simply called the move(new_position - old_position) to move the widget. It works to some extent, the widget does move but not so smoothly there's some problem, it sometimes goes to the top left corner. It just doesn't work correctly some of the times.
    Apparently you are not doing any checks on the data you receive.

    Have you seen the [wiki]Moving widgets[/wiki] article in our wiki?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Giving user facility to resize widgets run time

    How did you implement the resizeEvent function ?
    When you are adding the widget to the scene, it becomes a graphics item. May be you will need to enable QGraphicsItem::ItemIsMovable.

  4. #4
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Giving user facility to resize widgets run time

    Quote Originally Posted by wysota View Post
    Have you seen the [wiki]Moving widgets[/wiki] article in our wiki?
    Thanks a ton. The article helped. Now I can move my widgets without any problem.
    Though one quick question. Before reading this article i was using globalPos() to find the position of the event occurrence and then was using it to move the widget. According to the documentation, mapToParent(), used in the article, does the same. Then why is it that the app works fine with the latter and not with the former?

    When the widget is resized.
    Ya but how should the widget be resized? I want a functionality in which the widget should be able to be resized by the user run time with the help of mouse, like we do it in Qt Designer. I don't want to do it through programming.


    Added after 4 minutes:


    Quote Originally Posted by aamer4yu View Post
    When you are adding the widget to the scene, it becomes a graphics item. May be you will need to enable QGraphicsItem::ItemIsMovable.
    I am adding the widgets in the GraphicsView run time, by drag and drop. There is a list of widgets on one side and Qt GraphicsView on the other side. When the user drags and drops the widget name on the graphics view it is replaced by the widget instance. So the widgets are being added run time. And about the ItemIsMovable flag, I think it is true by default.
    Last edited by Charvi; 20th March 2012 at 09:50.

Similar Threads

  1. Replies: 6
    Last Post: 7th February 2012, 02:03
  2. Widgets: Let the user change the size
    By Donner in forum Qt Programming
    Replies: 2
    Last Post: 14th November 2010, 20:13
  3. QSplitter only resize from user input?
    By winston2020 in forum Qt Programming
    Replies: 1
    Last Post: 30th January 2009, 15:50
  4. how do I discard user changes on widgets
    By donglebob in forum Qt Programming
    Replies: 5
    Last Post: 30th December 2008, 07:50
  5. Replies: 3
    Last Post: 3rd September 2008, 16:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.