Results 1 to 3 of 3

Thread: Graphics widget with background

  1. #1
    Join Date
    Jun 2007
    Location
    Louisiana
    Posts
    77
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Graphics widget with background

    I am attempting to create a widget with a .PNG background and is drawn over with a rotating graphic. The problem is that I am unable to get both to occur at the same time. Either I get the background to show but I can't see what is drawn over it, or the objects that are drawn over the background show up but the background does not.

    The documentation is confusing at best so I am seeking advice here. I have seen the examples for graphics view (colliding mice) and the code works as is. I just have not been able to get a similar effect to work in a widget of my own even using that exact code slightly modified to be a widget.

    environment: WinXP and SUSE Linux 10.2 Qt 4.3.1 open source and MinGW with eclipse

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphics widget with background

    Well, you'll have to post the code, because it is impossible for someone to say what is wrong.

    Regards

  3. #3
    Join Date
    Jun 2007
    Location
    Louisiana
    Posts
    77
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Graphics widget with background

    Well I was able to get the background to show using the stylesheet of the window. This put the graphic as a background for the window. It took some doing as there seems to be some bug in Qt 4 where you have to have a repaint event (even an empty one) for it to show. I discovered that this is not what I wanted anyway. This method displays the graphic with original dimensions and uses the window view area to crop if smaller or fill if larger. This action is like a MS Windows wallpaper image. Not what I had in mind.

    I later ran across QScrollArea as a container for a control like a label. So I changed my project to have a QScrollArea that contains a label that has my graphic as a pixmap. The label widget is set to scale as the QScrollArea contents. Now each time the window resizes, so does the scroll area and the graphic in the label.

    Hope this helps those who have run across this problem.

Similar Threads

  1. Background image for main window widget using css.
    By Enygma in forum Qt Programming
    Replies: 8
    Last Post: 23rd August 2007, 16:40
  2. Background image and semitransparent widget
    By asieriko in forum Qt Programming
    Replies: 3
    Last Post: 20th August 2007, 17:43
  3. transparent background of the main widget
    By nagpalma in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2007, 18:52
  4. Grabbing widget's background
    By jpn in forum Qt Programming
    Replies: 4
    Last Post: 14th May 2006, 08:58
  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.