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.

Qt Code:
  1. MainWindow::MainWindow(QWidget *parent):
  2. QMainWindow(parent)
  3. {
  4. this->setupUi(this);
  5. m_hwnd = this->viewPage->winId(); //viewPage is a QFrame
  6. ...
  7. }
To copy to clipboard, switch view to plain text mode 

It works properly.
OK.jpg

but when I write like this
Qt Code:
  1. MainWindow::MainWindow(QWidget* parent):
  2. QMainWindow(parent)
  3. {
  4. ...
  5. this->setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::FramelessWindowHint);
  6. this->setAttribute(Qt::WA_TranslucentBackground, true);
  7. m_hwnd = this->viewPage->winId();
  8. ...
  9. }
To copy to clipboard, switch view to plain text mode 

It doesn't work. I don't know why...
setWindowFlags.png

I think winId() is invalid if does not have the frame. So I try to new other QFrame and setWindowFlags.
Qt Code:
  1. MainWindow::MainWindow(QWidget *parent):
  2. QMainWindow(parent)
  3. {
  4. ...
  5. this->setWindowFlags(Qt::WindowMinimizeButtonHint | Qt::FramelessWindowHint);
  6. this->setAttribute(Qt::WA_TranslucentBackground, true);
  7. QFrame* frame= new QFrame();
  8. frame->setWindowFlags(Qt::FramelessWindowHint);
  9. frame->show();
  10. m_hwnd = frame->winId();
  11. ...
  12. }
To copy to clipboard, switch view to plain text mode 

It's OK, although QFrame out of the QMainWindow.
Other Widget.jpg

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.