Results 1 to 2 of 2

Thread: How to create transparent widgets on top of GLWidget

  1. #1
    Join Date
    Sep 2016
    Qt products

    Default How to create transparent widgets on top of GLWidget

    Hi everyone,
    I am quite new to OpenGL programming, and i have a problem while creating transparent widgets over glWidget. I am using Qt 4.2 with C++ on centOs(linux) operating system. The requirements of my project are: to create a glwidget on the screen with some drawing(circles, shapes and so on). then we need to create some transparent widgets over the openGL widget in such a way that the drawing over glWidget should be visible under the new child widgets.
    The main files i have created is:
    First i have a main Widget (Form), and a child openGLWidget on the top of the main widget. Now the problem is that when i am creating transparent child widgets over the glWidget, then the system desktop is visible under the child widget instead of the drawing over glWidget. Some part of my code is:

    Qt Code:
    1. //constructor of MainWindow:
    2. // object of GLWidget
    3. glWidget = new GLWidget();
    4. glWidget ->setParent(this);
    5. glWidget ->resize(1024,800);
    6. glWidget ->show();
    8. //creating object for child widget
    9. childWidget = new Form(glWidget );
    10. childWidget ->setParent(glWidget);
    11. childWidget ->setGeometery(1024-320,300,300,300);
    12. childWidget ->show();
    15. //constructor of child widget which should be transparent over the above glWidget
    16. widget.setupUi(this);
    17. setWindowFlags(Qt::FrameLessWindowHint);
    18. setAutoFillBackground(false);
    19. setAttribute(Qt::WA_NoSystemBackground);
    20. setAttribute(Qt::WA_TranslucentBackground);
    21. setAttribute(Qt::WA_PaintOnScreen);
    22. setAttribute(Qt::WA_TransparentForMouseEvents);
    23. setAttribute(Qt::WA_ContentsPropagated);
    To copy to clipboard, switch view to plain text mode 
    Any help will be appreciated.

    Last edited by Anwar Said; 7th September 2016 at 15:47.

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    Default Re: How to create transparent widgets on top of GLWidget

    "Circles, shapes and so on" are not good candidates for widgets. Instead you can implement your GL code in paintGL() and paint your shapes in paintEvent() of a QGLWidget.
    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. Replies: 2
    Last Post: 8th December 2015, 13:26
  2. Widgets on top of GLWidget on MacOS
    By GdelP in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2013, 14:06
  3. Replies: 0
    Last Post: 30th September 2010, 14:22
  4. Replies: 2
    Last Post: 31st May 2010, 12:57
  5. Transparent widgets
    By incapacitant in forum Newbie
    Replies: 10
    Last Post: 21st March 2006, 19:01

Tags for this Thread


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.