Results 1 to 3 of 3

Thread: About FramelessWindowHint and winId

  1. #1
    Join Date
    Dec 2010
    Posts
    33
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default About FramelessWindowHint and winId

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: About FramelessWindowHint and winId

    I think winId() is invalid if does not have the frame.
    Did you call setupUi() in the second case?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Dec 2010
    Posts
    33
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: About FramelessWindowHint and winId

    It's OK now!

    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, false); //< Can't set translucentBackground true
    7. m_hwnd = this->viewPage->winId();
    8. ...
    9. }
    To copy to clipboard, switch view to plain text mode 

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

Similar Threads

  1. winId() crashed
    By nedivi in forum Qt Programming
    Replies: 1
    Last Post: 6th March 2011, 23:03
  2. Can't get Widget from WinID()
    By abbapatris in forum Qt Programming
    Replies: 3
    Last Post: 9th July 2008, 17:25
  3. setWindowFlags(Qt::FramelessWindowHint)
    By smarinr in forum Qt Programming
    Replies: 5
    Last Post: 30th April 2008, 20:12
  4. Winid issue with Qt
    By Pragya in forum Qt Programming
    Replies: 6
    Last Post: 7th June 2007, 13:10
  5. Qt::FramelessWindowHint
    By L.Marvell in forum Qt Programming
    Replies: 16
    Last Post: 6th May 2006, 16:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.