[Interest] QDialog with transparent background on iOS

Hamish Moffatt hamish at risingsoftware.com
Mon Feb 23 07:14:52 CET 2015


I'd like to pop up a dialog on top of other widgets on iOS as if it's a 
pop-up window (message box etc). My application is pure widgets and I'm 
using Qt 5.4.0.

It seems that windows are always maximized on the iOS platform, so I put 
everything inside a QFrame and positioned the frame where I want the 
window to appear to be. However, I can't get the background of the 
window to be transparent.



In Qt 4 it was possible by setting "background: transparent" in the 
stylesheet for that element, and the WA_TranslucentBackground|| window 
attribute. However this is not having any effect in Qt 5. I'm able to 
set colours ok (and I can make the whole window translucent with 
setOpacity), but I can't get the background itself to be transparent.

I'm creating the dialog as follows;

TMobileTopicInfo::TMobileTopicInfo(bool error, const QString& heading, const QString& body, QWidget *parent)

: QDialog(parent, Qt::Dialog| Qt::FramelessWindowHint)

{

     setAttribute(Qt::WA_TranslucentBackground, true);

     //setAttribute(Qt::WA_NoSystemBackground, true); // tried - doesn't seem helpful.


     mUi.setupUi( this );

     //...

}


The window background is black, on both iOS and on Windows.

There's suggestions on StackOverflow that the window flags should be 
overriden to change the window type to QWidget instead of QDialog. This 
actually seems to work (the background is transparent), but then there 
seem to be widget focus issues on iOS.


Any suggestions?


Thanks

Hamish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150223/0f0046a3/attachment.html>


More information about the Interest mailing list