Results 1 to 20 of 23

Thread: Qt::Popup with titlebar

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Posts
    22
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Qt::Popup with titlebar

    Hi,

    I have a subclass of QWidget. And I have set windowFlags to Qt::Popup in the constructor. But when popup widget is displayed, it comes without titlebar. I have also tried Qt::Popup | Qt::WindowTitleHint. But it's still displayed without titlebar.

    How can I get popup with title bar?

    Please reply.

    Thanks & Regards,
    Keyur Shah

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt::Popup with titlebar

    With Qt::Popup you wont get the title bar.
    Dont set any flags, and you will get the widget with a title bar. You can also use QDialog , or QWidget with Qt::Tool flag set,, whatever suits you.

  3. #3
    Join Date
    Jan 2010
    Posts
    22
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt::Popup with titlebar

    Thanks for your reply.

    Oh... But none of other flags gives me what i wants.
    QDialog are providing only application specific functionaliy.

    I want my widget to close if user clicks outside the widget or better outside the application too.

    So how can I get such things without using Qt::Popup flag?

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt::Popup with titlebar

    Well, if thats the case, I can think only of the following for now -
    Draw the title bar yourself in the paintevent of your widget. And you can have the Qt::Popup flag set on your widget too

  5. #5
    Join Date
    Jan 2010
    Posts
    22
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt::Popup with titlebar

    Is there any method using which I can draw titlebar of widget by myself?

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt::Popup with titlebar

    QStylePainter::drawComplexControl(QStyle::CC_TitleBar,option);

  7. #7
    Join Date
    Jan 2010
    Posts
    22
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt::Popup with titlebar

    Still it is diaplyed without titlebar.

    I have written following code in paintEvent

    QStylePainter painter( this );
    QStyleOptionTitleBar option;
    painter.drawComplexControl( QStyle::CC_TitleBar, option );

    Please let me know if I am missing something.

  8. #8
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt::Popup with titlebar

    try setting option.initFrom(this);
    But I doubt if QStyle will permit you draw a title bar on a Qt::Popup widget.

    You can try setting the QStyleOptionTitleBar::titleBarFlags and see if draws.

  9. #9
    Join Date
    Jan 2010
    Posts
    22
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt::Popup with titlebar

    How to set QStyleOptionTitleBar::titleBarFlags???

    Do you mean set the widget->setWindowFlags(Qt::WindowTitleHint) ?

  10. #10
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt::Popup with titlebar

    What is the exact functionality you want and get with Qt::Popup and you can't get with other flags?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  11. #11
    Join Date
    Jan 2010
    Posts
    22
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt::Popup with titlebar

    With Qt::Popup, If I click anywhere including outside application, only the popup will be dismissed and no other window has any effect.

Similar Threads

  1. Mac titlebar buttons Issue.
    By kaushal_gaurav in forum Qt Programming
    Replies: 5
    Last Post: 9th July 2009, 21:45
  2. Replies: 3
    Last Post: 17th May 2009, 20:17
  3. TitleBar color
    By chethana in forum General Programming
    Replies: 1
    Last Post: 14th November 2008, 17:20
  4. Color of Titlebar and Menubar
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 16th August 2007, 10:12
  5. QMainWindow with no titlebar in OSX
    By xgoan in forum Qt Programming
    Replies: 3
    Last Post: 22nd February 2007, 12:15

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.