November 25, 2010

puelocesar puelocesar
Lab Rat
32 posts

(Solved) Transparent Windows

 

Hi everybody, I’m creating a Qt Quick application for Desktop, and we need to make it borderless and with custom shape. I’m doing this this way:

  1. int main(int argc, char *argv[])
  2. {
  3.     QApplication app(argc, argv);
  4.  
  5.     QmlApplicationViewer viewer;
  6.     viewer.setWindowFlags(Qt::FramelessWindowHint);
  7.     viewer.setAttribute(Qt::WA_TranslucentBackground);
  8.     viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
  9.     viewer.setMainQmlFile(QLatin1String("qml/ParesTest/main.qml"));
  10.     viewer.showExpanded();
  11.  
  12.     return app.exec();
  13. }

The thing is, opacity on parent node on main.qml doesn’t work. If this parent node is a Rectangle, and I set its opacity to 0, I’ll get an white rectangle on desktop. Is there any option to set on QmlApplicationViewer or this isn’t supported?

By the way, unfortunately, I’m using Windows 7..

9 replies

November 25, 2010

puelocesar puelocesar
Lab Rat
32 posts

Solved!

  1. viewer.viewport()->setAutoFillBackground(false);

Above code solved the problem :)

November 25, 2010

Cezary Tomczak Cezary Tomczak
Lab Rat
16 posts

You might encounter a serious limitation when using transparent window with a custom frame in qml – minimizing application makes the qml interface broken (on windows xp), see the bug I’ve reported here:

http://bugreports.qt.nokia.com/browse/QTBUG-15429

Or maybe you’ve got some solution? Then post it here, thanks.

November 25, 2010

puelocesar puelocesar
Lab Rat
32 posts

Well, I can minimize and restore the Qml window and still see the contents, but it’s pretty raw, just two rectangles on the screen.. Tomorrow when I arrive at work, I will test if I also have this hovering problem.

Thanks for the tip

November 25, 2010

Cezary Tomczak Cezary Tomczak
Lab Rat
16 posts

Yeah, it’s MouseArea objects that are broken. I see that you’re initializing it in a different way using QmlApplicationViewer, I’m doing it another way by extending QDeclarativeView (but also tried inside QMainWindow but it didn’t help). So maybe your code won’t encounter the hover bug, who knows. I see that you’re testing on Windows 7, but if it works, if you could test it also under Windows XP please let me know, thanks.

November 25, 2010

Cezary Tomczak Cezary Tomczak
Lab Rat
16 posts

Btw. I’ve already implemented dragging and resizing my custom framed window, also maximizing works fine (by default you may encounter a problem that maximize makes the window fullscreen, hiding the taskbar, I have it resolved). So if you have some problems I might be able to help you.

Ahh and I also have custom drawn cursors working (default pointer and resize cursors) :)

November 26, 2010

puelocesar puelocesar
Lab Rat
32 posts

I have the same problem with broken interface on minimize…

November 26, 2010

Cezary Tomczak Cezary Tomczak
Lab Rat
16 posts

There is an another issue with transparent qml windows: dragging and resizing is very slow, on old computers (1.5 ghz, 1 core) the window is jumping and makes it a bad user experience.

November 29, 2010

Patrick Burke Patrick Burke
Lab Rat
16 posts

Have you tried changing the renderer to a different one, like opengl? Some of them are faster on different hardware then others.

November 29, 2010

Cezary Tomczak Cezary Tomczak
Lab Rat
16 posts

Yes, I tried opengl, but I get white screen with only some of the interface being drawn.

http://bugreports.qt.nokia.com/browse/QTBUG-15429?focusedCommentId=133846#comment-133846

 
  ‹‹ help with text in lineEdit      [SOLVED] Transitions between screens ››

You must log in to post a reply. Not a member yet? Register here!