Results 1 to 5 of 5

Thread: Flickering custom titlebar

  1. #1
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Exclamation Flickering custom titlebar

    Hi all,
    I have a class inherited from QDockWidget to set a custom titlebar in the constructor (to avoid to set each time).
    All works good but when I have the QMainWindow loading I have flickering each time a dock is added.
    If I use just a QDockWidget, not my custom class with titlebar, I don't see the flickering at all.
    Here the code of the custom dock widget, CTitlebarWidget uses parent() to access the dock.
    Qt Code:
    1. CDockWidget::CDockWidget( const QString& Title, QWidget* Parent ) :
    2. QDockWidget( Title, Parent )
    3. {
    4. m_Titlebar = new CTitlebarWidget( this );
    5. setTitleBarWidget( m_Titlebar );
    6. }
    7.  
    8. bool CDockWidget::event( QEvent* event )
    9. {
    10. switch( event->type() )
    11. {
    12. case QEvent::WindowTitleChange :
    13. {
    14. m_Titlebar->SetTitle( windowTitle() );
    15. return true;
    16. }
    17.  
    18. case QEvent::NonClientAreaMouseButtonDblClick :
    19. {
    20. if( isMaximized() )
    21. showNormal();
    22. else
    23. showMaximized();
    24. return true;
    25. }
    26. }
    27. return QDockWidget::event( event );
    28. }
    To copy to clipboard, switch view to plain text mode 
    Why flickering is visible ? There are visible only on loading.
    That's like if dock is floating for a little time.
    Thanks for the help

  2. #2
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    Wiki edits
    7

    Default Re: Flickering custom titlebar

    Have you tried creating all of the dock widgets (custom or otherwise) with the QMainWindow hidden, and only after everything is created calling mainWindow.show()?

  3. #3
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Flickering custom titlebar

    Gives the same result using that :
    Qt Code:
    1. CMainEditorWindow::CMainEditorWindow()
    2. {
    3. hide();
    4. ...
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 
    All my dock use the custom QDockWidget to have the custom title bar, if I change all using QDockWidget from Qt I don't have flickering.

  4. #4
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    Wiki edits
    7

    Default Re: Flickering custom titlebar

    I meant creating your docks and setting their custom title bars before the absolute first call to QMainWindow.show() in your program.
    QMainWindow is hidden at the moment you create it, so it's possible that it will hide that flickering if you prepare your widgets while it's like this.

  5. #5
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Flickering custom titlebar

    Apparently the problem of flickering is because the widget created in the TitleBarWidget constructor doesn't use "this" as parent, using "this" the flickering is out but my layout is now not good visually, I have to find how recode it to be like before. I tried a QLinedEdit as titlebar and I saw the flickering was out, like that I found the answer.
    EDIT:
    SOLVED, but I need something tell me if that's correct. I have all widget using "this" as parent but the layout has no parent, then I use at the end "setLayout( Layout );".
    setLayout set the layout to the new parent or a memory leak is present ?
    EDIT:
    Apparently the doc do like I do :
    http://doc.qt.io/qt-5/qwidget.html#setLayout
    All looks ok
    Last edited by Alundra; 24th January 2015 at 01:58.

Similar Threads

  1. how to draw custom titlebar for QMainWindow ... ?
    By pradeepreddyg95 in forum Qt Programming
    Replies: 5
    Last Post: 13th May 2017, 09:23
  2. Replies: 0
    Last Post: 18th November 2014, 04:39
  3. QFrame with QDockWidget using custom titlebar
    By Alundra in forum Qt Programming
    Replies: 0
    Last Post: 7th March 2014, 16:30
  4. Replies: 6
    Last Post: 16th April 2013, 16:13
  5. custom widget with the windows7 style titlebar??
    By pirlogy in forum Qt Programming
    Replies: 1
    Last Post: 21st May 2011, 00:30

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
  •  
Qt is a trademark of The Qt Company.