PDA

View Full Version : About FramelessWindowHint and winId



Wong
18th May 2011, 07:34
Hi guys:
I got a problem that seems to be very strange. I want to write a media player with some dll, argument is window HWND. So I input QFrame::winId(). That qframe is child of qmainwindow.



MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent)
{
this->setupUi(this);
m_hwnd = this->viewPage->winId(); //viewPage is a QFrame
...
}


It works properly.
6441

but when I write like this


MainWindow::MainWindow(QWidget* parent):
QMainWindow(parent)
{
...
this->setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground, true);
m_hwnd = this->viewPage->winId();
...
}


It doesn't work. I don't know why...
6439

I think winId() is invalid if does not have the frame. So I try to new other QFrame and setWindowFlags.


MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent)
{
...
this->setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground, true);
QFrame* frame= new QFrame();
frame->setWindowFlags(Qt::FramelessWindowHint);
frame->show();
m_hwnd = frame->winId();
...
}


It's OK, although QFrame out of the QMainWindow.
6440

Now, I want custom titlebar. And get frame winId to play file...
I do not know where to begin, and unable to perceive where the problem lay.

Please, help me.
Thanks.

high_flyer
18th May 2011, 13:55
I think winId() is invalid if does not have the frame.
Did you call setupUi() in the second case?

Wong
19th May 2011, 09:19
:( It's OK now!



MainWindow::MainWindow(QWidget* parent):
QMainWindow(parent)
{
...
this->setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground, false); //< Can't set translucentBackground true
m_hwnd = this->viewPage->winId();
...
}


Although play properly, but I want set QMainWindow's style sheet (border-radius:8px).
How should I do?