Qt::NoOpaqueDetection
-
Hi Guys
Apologies I'm a noob,what I want to do is set the flag Qt::NoOpaqueDetection when creating my QPixmap.
I've searched for ages with no luck.
How exactly do I set this flag when creating my pixmap like below, is it possible?Myicon->setOnPixmap(QPixmap(myimage);
Something like this but this doesnt work
Myicon->setOnPixmap(QPixmap(myimage, Qt::NoOpaqueDetection);
-
Qt::NoOpaqueDetection is a flag for a QImage conversion, not for something during drawing. What do you want to achieve and why do you think you need this flag?
-
@Christian-Ehrlicher Ah ok, thank you
When I click on my QPixmap when it is within a QLabel the click only registers on the non-opaque sections of the PNG image.
I want to register a click on the entire 200x200 PNG, as it can be difficult for the user to press the button when they must hit the non-transparent bits.
So i thought that flag would turn off opaque detection. (I need to maintain transparency for appearances and I must maintain using QLabel)
The search continues... -
Do you display a transparent QLabel? Please show some code.
-
@Christian-Ehrlicher Yes The problem line is
icon->setAttribute(Qt::WA_TranslucentBackground, true);
If I remove that line i can click the entire PNG image of 200x200 pixels but I lose the transparency.
Need to maintain transparency but also click area.mainArea::mainArea(QWidget *parent) :QLabel(parent) icon->setObjectName(name); icon->setGeometry(QRect(x, y, w, h)); icon->setOnPixmap(QPixmap(imgOnInd_dm)); icon->setOffPixmap(QPixmap(imgOffInd_dm)); icon->setWindowFlags(Qt::Window | Qt::FramelessWindowHint); icon->setVisible(vis); QObject::connect(icon, SIGNAL(clicked()), this, SLOT(btnClicked()));
-
This is not possible afaik since the window manager will not send events to this QLabel when the click is on an opaque pixel.
-
@Christian-Ehrlicher Ok thanks for that, it'll save me looking any further