Results 1 to 4 of 4

Thread: how to fix widget location

  1. #1
    Join Date
    Nov 2007
    Posts
    47
    Thanks
    34
    Qt products
    Qt4
    Platforms
    Windows

    Default how to fix widget location

    Hello.
    I'd like the top left corner of my widget (a QLabel) to stay fixed relative to the main layout so that when I 1) resize the window, 2) change the size of the widget, 3) change the identity of the widget, the absolute coordinate (relative to the main layout) of my widget is not changed. I know that stretch can't do what I want.
    Thanks in advance!

  2. #2
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to fix widget location

    Could you write some more about your window?
    Are you using layout, which one if you do, how widgets are places on window(is your label topmost of leftmost, or is it placed elsewhere)?
    and what is actual behavior?
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

  3. #3
    Join Date
    Nov 2007
    Posts
    47
    Thanks
    34
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to fix widget location

    Hi Mchara,

    Thanks for your response.
    My main layout is QVBoxLayout, this contains two QHBoxLayouts. The top QHBoxLayout contains QLabel which is a QPixmap. I crop this pixmap with mouse and I'd like it to stay in the top left corner of my window (whatever I do to it). When I crop my pixmap I use mapFromParent to get the local coordinates. If the pixmap jumps around in the window (while zooming or cropping) it's very difficult to keep the coordinates straight. That's why I'd like to nail the top left corner of my pixmap to the main window.
    I know there might be other ways to reliably obtain the coorinates and fixing the pixmap may not sound critical for that but I'd really prefer this approach (the reason being that other changes will negatively affect the program of which the pixmap is part).
    Thanks again.

  4. #4
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to fix widget location

    so, u may try to set sizepolicies in a different way
    i.e. QSizePolicy::Minimum in both directions shall keep widget's size expanded to whole free place in your window with pixmap in top-left corner (The widget,s size should be larger than pixmap's size).
    You may also consider puting QLabel with pixmap into QScrollArea - you'll get automatically scrollbars if pixmap would be larger than widget.
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

Similar Threads

  1. Replies: 3
    Last Post: 17th October 2007, 13:52
  2. Custom tab widget question
    By PrimeCP in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 12:17
  3. transparent background of the main widget
    By nagpalma in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2007, 18:52
  4. Controlling which widget on top layer?
    By JonathanForQT4 in forum Qt Programming
    Replies: 6
    Last Post: 22nd March 2007, 15:27
  5. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 15:16

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.