[英]Frameles and transparent Window does not work! Qt widget
I'm using Qt widget. 我正在使用Qt小部件。
I needed a dialog that shows when I click on a button on my main window that dialog should be transparent meaning if I opened it I still can see the background like there's nothing there. 我需要一个对话框,该对话框显示当我单击主窗口上的按钮时该对话框应该是透明的,这意味着如果打开它,我仍然可以看到背景,就像那里什么都没有。
I tried this in the constructor of my dialog: 我在对话框的构造函数中尝试了此操作:
this->setWindowFlags(Qt::Widget | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground,true);
this->setWindowState(Qt::WindowFullScreen);
To make it more clear here's the mouse events: 为了更加清楚,这是鼠标事件:
void FramelessWindow::mousePressEvent(QMouseEvent *event){
if(event->button()==Qt::LeftButton){
origin= event->pos();
rubberBand->setGeometry(QRect(origin,QSize()));
rubberBand->show();
}
}
void FramelessWindow::mouseMoveEvent(QMouseEvent *event){
rubberBand->setGeometry(QRect(origin,event->pos()).normalized());
}
void FramelessWindow::mouseReleaseEvent(QMouseEvent *event){
rubberBand->hide();
}
*Edit: *编辑:
After spending nearly 12 hours trying to figure out how to solve this , I just couldn't :( I tried everything but it doesn't work , hopefully there's another method to do the same thing ? i'm on windows 8.. 在花费了将近12个小时的时间来弄清楚如何解决这个问题之后,我只是无法:(我尝试了一切,但没有用,希望有另一种方法可以做同样的事情?我在Windows 8上。
*Edit 2: *编辑2:
Yeah I'm using windows 8.. 是的,我正在使用Windows 8。
And what I meant about " used everything " is that I've done everything in google, tried this guy's method: 我所说的“用尽一切”的意思是,我已经完成了google的所有工作,尝试了使用此方法:
http://qt-project.org/forums/viewthread/42406/ http://qt-project.org/forums/viewthread/42406/
and this guy: 这个家伙:
http://www.qtcentre.org/threads/53362-Qt5-Translucent-alpha-channel-problems http://www.qtcentre.org/threads/53362-Qt5-Translucent-alpha-channel-problems
still it didn't work... 仍然没有用...
.. ..
ok is there another method to grab the mouse events ? 好的,还有另一种捕获鼠标事件的方法吗? where for example the user can press and drag and then release and I get the coordinates so I can take pictures and stuff like that , the user needs to see the background , that's why I said it needs to be transparent.
例如,在用户可以按下并拖动然后释放的位置,我得到了坐标,因此我可以拍摄照片之类的东西,用户需要查看背景,这就是为什么我说它需要透明的原因。
If you are using Qt 5.2 you may like to have a look at this Qt Windows Extras: 如果您使用的是Qt 5.2,则可能需要看一下Qt Windows Extras:
http://qt-project.org/doc/qt-5/qtwinextras-overview.html http://qt-project.org/doc/qt-5/qtwinextras-overview.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.