Results 1 to 5 of 5

Thread: Changing widget position overlay on another widget while screen is resizing

  1. #1
    Join Date
    Jul 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Changing widget position overlay on another widget while screen is resizing

    Good day experts

    I am designing an application for a data acquisition system using Qt. i need to place led control controls on picture that show the layout of the acquisition system. actually the led indicate the state of some sensors(safe,warning,alarm) shown on the picture as marker. when the screen resizes meaning that the picture sizes increases i need these leds to follow the marker position so that a led is always on a given marker.

    I have tried to reimplement the event resize method. I designed the gui with a given size, use that size width to position the led widget at a specific location on a marker when the gui is launched.When the users increases the screen size i tried to get the new screen width divide by some factor and passed it to the led for a new position. but the pos() only accept integers so the led cant be quite on the marker. also these seems to work for big difference between screen sizes change(the led approaches at least the marker). with small increments my algorithm the positioning is not working.

    lastly, i tried to design the gui for two screen sizes. the one that its get when launched and the one that it will get when completely maximized. this seems to work. but only if you don't tried any other screen resized in between. i am thinking of blocking any other screen sizes but these two.I have attached a picture of what i trying to do.


    Been looking around and trying stuff don't seems to solve my problem.any help would be much appreciated.

    Thanks in advance.
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Changing widget position overlay on another widget while screen is resizing

    How do you display the images?

    How do you resize them? I.e. is it the same image and it gets scaled or do you load a new image for the new size?

    Cheers,
    _

  3. #3
    Join Date
    Jul 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Changing widget position overlay on another widget while screen is resizing

    Hello thanks for considering my issue.

    Actually the markers are on an image that is the pixmap of a qlabel. the leds are widgets parented by the qlabel. The image resizes as the application screen is resized. no new image. since the qlabel is the app central widget it resizes as the app resizes i think.I then tried to use resize event to change the leds positions

    Again, Thanks for helping out!

    Regards,
    newOverlay.jpg
    Last edited by mys2015; 24th August 2015 at 03:10. Reason: spelling corrections

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Changing widget position overlay on another widget while screen is resizing

    Ah, so the image is drawn and resized by a QLabel?

    I would suggest a different approach:
    - create a custom QWidget derived class
    - let it scale and draw the image
    - let it also draw the "leds"

    You can then also experiement with scaling the painter and drawing image and leds in their original coordinates.

    Cheers,
    _

  5. #5
    Join Date
    Jul 2015
    Posts
    4
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Changing widget position overlay on another widget while screen is resizing

    hello anda_skoa!

    I am not quite sure if i understand what you saying. The Qlabel image i am getting it from a resource file.Do you mean using qpainter to redraw the leds each time the screen is resized? the custom qwidget, should it just be a class that inherit from qwidget?

    can you please explain a bit more or provide a sample?

    Regards,

Similar Threads

  1. Replies: 1
    Last Post: 11th April 2012, 08:45
  2. Replies: 0
    Last Post: 22nd March 2010, 19:00
  3. Resizing child widget on changing size of parent?
    By anupamgee in forum Qt Programming
    Replies: 3
    Last Post: 13th November 2009, 09:39
  4. Layout (widget overlay)
    By whitefurrows in forum Qt Programming
    Replies: 3
    Last Post: 4th July 2009, 00:54

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.