Results 1 to 8 of 8

Thread: How to set a widget as background?

  1. #1
    Join Date
    Aug 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to set a widget as background?

    What I need is:

    1 the background widget should resize with window automatically
    2 I need to put some other witgets on(I mean over or cover) the background one

    the straightest way of 1 is using form layout, but then everything is in the layout and I can't put any wighets on others. So is there anything to do it?

    Thanx a lot!

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to set a widget as background?

    I am not sure I follow.
    What (usability) sense does it make to put widgets as background (meaning you can't see them or only partly)?
    Can you give a user case example to what you need?
    It sounds like you are trying to solve a problem in the wrong way...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Aug 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set a widget as background?

    Mmm... sorry for not expressing clearly. here I explain again

    I just want one widget to fill almost the whole area of the form which seems like a 'background', while other widgets are all 'on' it. Of course the 'background' widget can be seen only partly. It happens when I use QVTKWidget to represent a chemical reactor, and want to add some 'clock' widget over the view of the reactor. I'm not sure if it's more clear.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to set a widget as background?

    Do you mean placing child widgets on top of parent widget?
    If this is what you mean, what is the problem exactly doing that?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Aug 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set a widget as background?

    I don't think so... I mean that I want to put a smaller widget in front of a larger one, and the larger one should fill the whole form... no other relationship between them...

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to set a widget as background?

    Well, then just create the "top" widget to be a child of your form (like your "background" widget) and set its Z order to be in front of your "background" widget, and don't place it in a layout, rather position it manually.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Aug 2010
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set a widget as background?

    mmm... so how could I set the background widget to resize automatically with the form through manually size settings?

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

    Default Re: How to set a widget as background?

    Reimplement resizeEvent() for the top-level widget or put the background widget in a layout. In general I think you are trying to do something terribly wrong here. I think your "background" should be your "foreground" and your "foreground" should be a child widget (or child widgets) of your "background".
    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.


Similar Threads

  1. Widget as desktop background
    By abeinoe in forum The GraphicsView Framework
    Replies: 0
    Last Post: 30th January 2009, 07:15
  2. Widget background problem.
    By zgulser in forum Qt Tools
    Replies: 2
    Last Post: 6th January 2009, 06:34
  3. Qwt overrides Widget background
    By garfield in forum Qwt
    Replies: 1
    Last Post: 18th December 2007, 08:16
  4. Graphics widget with background
    By ad5xj in forum Newbie
    Replies: 2
    Last Post: 24th August 2007, 16:29
  5. Grabbing widget's background
    By jpn in forum Qt Programming
    Replies: 4
    Last Post: 14th May 2006, 07:58

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.