Results 1 to 6 of 6

Thread: Drawing widgets with transparent backgrounds over a specialized widget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Location
    www.JaminGrey.com
    Posts
    71
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Drawing widgets with transparent backgrounds over a specialized widget

    Hello. I'm trying to draw a QWidget over another QWidget that is drawn by the SFML API.

    Everything works fine, I have my main widget be Qt-controlled, I have additional widgets around the sides, and the center widget is a QScrollArea with the SFML QWidget owned by the QScrollArea.
    Events work fine, drawing works fine.

    However, when I give the SFML-drawn QWidget a layout and a child widget, despite everything I do, I can't see the SFML-drawn widget through the background of the child widget.

    It looks like this:
    blackbar.jpg

    The one on the left is behaving properly (it's outside the SFML widget), but the one on the right (a child of the SFML widget) with it's transparent background shows black instead of the background drawn by SFML.

    All my SFML drawing happens within the QPaint of the SFML QWidget.

    I've tried tons of different methods to try and get the background to be transparent.

    I've tried:
    Qt Code:
    1. QPalette p = rightTabBar->palette();
    2. rightTabBar.setBrush(QPalette::Window, Qt::transparent);
    3. rightTabBar->setPalette(p);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. rightTabBar->setObjectName("MyVerticalTabBar");
    2. rightTabBar->setStyleSheet("#MyVerticalTabBar { background-color: transparent; }");
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. rightTabBar->setAutoFillBackground(false);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. rightTabBar->setAttribute(Qt::WA_TranslucentBackground);
    To copy to clipboard, switch view to plain text mode 

    And:
    Qt Code:
    1. rightTabBar->setAttribute(Qt::WA_NoSystemBackground);
    To copy to clipboard, switch view to plain text mode 

    I'm under the sneaking suspicion that the background is properly transparent, but that the parent's background (the SFML-drawn widget) is somehow being propagated to the child before the SFML widget gets drawn, and that the child then draws the propagated blank background over the now-drawn background.
    Or else, maybe the child gets drawn first, and some kind of clip-rect gets set to the SFML-drawn window, keeping those pixels under the child from getting drawn (Despite Qt::WA_PaintUnclipped being set on the parent).
    Attached Images Attached Images
    Last edited by ComServant; 17th March 2012 at 21:14.

Similar Threads

  1. Freehand drawing on transparent widget.
    By vaibhav in forum Qt Programming
    Replies: 4
    Last Post: 24th November 2010, 06:33
  2. Replies: 2
    Last Post: 31st May 2010, 11:57
  3. Replies: 0
    Last Post: 15th May 2009, 15:38
  4. Widgets on Graphicsview backgrounds
    By pherthyl in forum Qt Programming
    Replies: 4
    Last Post: 29th July 2008, 18:02
  5. Regarding drawing on Transparent Window
    By Shalabh in forum Qt Programming
    Replies: 3
    Last Post: 31st May 2007, 10:32

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