Results 1 to 9 of 9

Thread: $20 to solve this webview transparency / drawing bug

  1. #1

    Default $20 to solve this webview transparency / drawing bug

    Source code found in Files.tar.gz

    Okay, I do not have much experience with C++ or QT. This issue has been kicking my ass for a long time, so I will give $20 via paypal to the first person who can solve it for me once in for all. I know its not much, but hopefully you will like the challenge. The attached code is largely complete. There are just small issues I am sure someone with more experience would know about right away.

    What I am trying to do:

    When someone left clicks in a widget then a popup box is shown to the user at the click location. The popup box may vary in size, shape (not always rectangle... Sometimes it is multiple connecting rectangles). The box (a qt webview widget) needs to disappear if anywhere on the screen is clicked much the same way that a context menu does. The size of the widget which contains the popup box must span the space of the screen and have a transparent background.

    The Problem

    Windows

    On windows, it largely works. The issue with windows is a flicker. Click once and it popups up as expected. Click again in a different area and for a split second you can see it in the previous area. There is no reason for it to do this. It is almost as if QT shows a cached version of what the menu used to look like before drawing the new version.



    Linux

    On linux, it is just a mess. The transparency does not work, so when the popup comes up it completely messes up what is in the background (it does not show a black background instead of transparent.... It shows whatever is behind the widget as it should, but then breaks it apart and randomizes all the pieces). And, probably a sympton of the same issue, the widget never redraws itself so just keeps on adding popup box after popup box. The only way to show the effect is with a picture. In the picture you will see blue boxes. That is the popup. The other stuff are just windows opened behind the application. As you can see, it completely messed up the desktop while it was open.



    The source code is in Files.tar.gz
    Attached Files Attached Files
    Last edited by TheNewGuy; 15th March 2010 at 23:49.

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: $20 to solve this webview transparency / drawing bug

    If I use my imagination I can see the desktop through the black. What distro are you running? I run Debian Sid, KDE 4.3.4 & Qt 4.6.0.
    Attached Images Attached Images

  3. #3

    Default Re: $20 to solve this webview transparency / drawing bug

    I run Ubuntu 9.10 with QT 4.6.2.

    I am not 100% positive on this, but I imagine you are getting a black background because you do not have compositing enabled. I have read that compositing must be enabled for transparency support in linux desktops.

  4. #4
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: $20 to solve this webview transparency / drawing bug

    Yeah, I have compositing enabled. I've had problems with transparency before. I have an older machine with a wimpy graphics card that doesn't have the horsepower to handle all of the desktop effects.

    Transparency issues aside, unless I misunderstand, I get the behavior that you describe for windows.

    Attached is a Gnome screenshot.
    Attached Images Attached Images

  5. #5

    Default Re: $20 to solve this webview transparency / drawing bug

    Yeah, the issue is only there if transparency is working. I have set the HTML document (menu.html) to have a black background before and the issue largely resolves itself. However, with transparency things go haywire. I am beginning to think that it is just a bug in QT. I have tried it on multiple systems with different graphic cards and the result is the same. I do not think it can be graphic card related because both systems I have tested it on are able to run compizfusion with every effect on. Since I do not understand how QT draws and everything I was hoping there was something fancy to do with paint events or something to get it to work or to at least stop the flickering on windows.

  6. #6
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: $20 to solve this webview transparency / drawing bug

    Sorry, I guess that I can't help since I ain't got no stinkin' transparency.

    Have you tried your app on a system running KDE?

  7. #7
    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: $20 to solve this webview transparency / drawing bug

    Do you open your popup as a real popup (i.e. with proper window flags)? The answer is probably in your code but I don't have time to look into it right now
    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.


  8. #8

    Default Re: $20 to solve this webview transparency / drawing bug

    The menu popup is created in the following way. Keep in mind I am new to QT and C++. I am sure it is not very pretty. I have literally tried a 100 different combinations of flags. This is just the latest (and the one in the test case). There is a good chance it is my code. I am probably doing something really dumb and obvious to anyone else.

    Qt Code:
    1. LHMenu::LHMenu()
    2. : LHWebView(), caller(0)
    3. {
    4. setWindowModality(Qt::ApplicationModal);
    5.  
    6. QPalette qpalette = palette();
    7. qpalette.setBrush(QPalette::Base, Qt::transparent);
    8. page()->setPalette(qpalette);
    9.  
    10. setAttribute(Qt::WA_OpaquePaintEvent, false);
    11. setAttribute(Qt::WA_TranslucentBackground, true);
    12.  
    13. setWindowFlags(Qt::FramelessWindowHint | Qt::SplashScreen);
    14.  
    15. page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
    16. page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
    17.  
    18. setContextMenuPolicy(Qt::NoContextMenu);
    19.  
    20. connect(page(), SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
    21.  
    22. load(QUrl("qrc:/menu.html"));
    23. }
    To copy to clipboard, switch view to plain text mode 

  9. #9
    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: $20 to solve this webview transparency / drawing bug

    That's not good. Try:
    Qt Code:
    1. setWindowFlags(Qt::Popup);
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. setWindowFlags(Qt::ToolTip);
    To copy to clipboard, switch view to plain text mode 

    Also try simplifying your code as much as possible. First of all see how everything behaves when you substitute QWebView with some other widget (say... QLabel).
    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. QProcess, how to give focus to the new process on Mac
    By simlab in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2010, 23:27
  2. How can I solve this?
    By srohit24 in forum Qt Programming
    Replies: 8
    Last Post: 7th April 2009, 07:00
  3. how to write RS232,give me some advice?
    By hiuao in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2007, 08:33

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.