Results 1 to 6 of 6

Thread: QDockWidget border

  1. #1
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QDockWidget border

    How to set up DockWidget so it has visible border around the edges?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDockWidget border

    Add a frame to it or subclass it and do the drawing yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    QPlace (13th July 2009)

  4. #3
    Join Date
    Jul 2007
    Posts
    121
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDockWidget border

    I am using the frame currently, with less then appealing visual results. I am trying to avoid widget custom painting at this stage of my project (and, khm-khm, knowledge of Qt). My question can be redefine as broader one:

    I re-read documentation on QWidget and from what I understood there is no such thing as "border" or "frame" property for a widget. The only reference is the flag Qt::MSWindowsFixedSizeDialogHint for top-level widgets only. This flag does exactly what I want, i.e drawing a thin line around the widget border. Take QPushButton for example, it has that type of border around it. But what is interesting to me is that I can't find exposed property for this widget where I can change a width of this frame. QTreeView, on the other hand, has (or is inhered from?) QFrame that is used as a widget boder and I can change border properties of QTreeView in design time.

    I am hoping that I missed something very basic in Qt, so my question is:
    In general - how to add/remove/edit "border" or "frame" of the stock widgets (buttons, lists, dockwidgets)? Or is it even possible and is there any other solution besides subsclassing and painting this basic stuff myself?

    And, regarding QDockWidget - isn't it strange that the default view of that widget has dialog caption for displaying the titiel and dragging, but no border around it?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDockWidget border

    You can design your own style or implement a style proxy that will introduce such changes but this involves drawing as well. I see no other choice.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    QPlace (13th July 2009)

  7. #5
    Join Date
    Jun 2008
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    1

    Default Re: QDockWidget border

    Is there an easy way to have a dock widget tear off into a QDialog?

    Floating QDockAreas are kind of a pain to work with, if I could tear it off into a dialog that would be sweet. (while still being able to move it from one dock area to another...)

  8. #6
    Join Date
    Jan 2011
    Posts
    70
    Thanks
    43
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDockWidget border

    I know this is an old thread, but my Google searches have brought me back to this page several times, so maybe we can help future searchers.

    I recently stumbled over the solution the OP was looking for here:
    http://doc.qt.io/qt-4.8/http://doc.qt.nokia.com/4.7-snapshot/stylesheet-examples.html#customizing-qmainwindow

    You're looking for the QMainWindow::separator{} style sheet. For example, in mainwindow.cpp:
    Qt Code:
    1. myMainWindow->setStyleSheet(
    2. "QMainWindow::separator {
    3. background: rgb(200, 200, 200);
    4. width: 2px;
    5. height: 2px;
    6. }");
    To copy to clipboard, switch view to plain text mode 

  9. The following user says thank you to Phlucious for this useful post:

    Nero (26th March 2013)

Similar Threads

  1. QDockWidget magically disapear
    By 1111 in forum Qt Programming
    Replies: 1
    Last Post: 29th January 2009, 11:44
  2. Showing QWidget border around the window
    By maverick_pol in forum Qt Programming
    Replies: 2
    Last Post: 20th March 2008, 20:14
  3. How to create a movable border between two widgets?
    By Teuniz in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2007, 08:45
  4. Replies: 8
    Last Post: 4th February 2007, 00:42
  5. QDockWidget flicker
    By fellobo in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2006, 20:42

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.