Results 1 to 19 of 19

Thread: QDockWidget-title

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2006
    Posts
    83

    Default QDockWidget-title

    Hello,

    I'm new in Qt and I have a problem with QDockWidget and the problem is that I can't remove the title bar in QDockWidget. I tried using the pixel metric but it doesn't work. I removed all of dockwidget features (in hope that the bar would go away but it didn't).
    Does anyone have any idea??

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDockWidget-title

    Maybe you could use QSplitter instead of a dock widget? A dock widget without title bar loses almost all of features specific to a dock widget.
    J-P Nurmi

  3. #3
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QDockWidget-title

    I know that. I use dockwidget because I have another dockwidget and it can dock under the first dockwidget (forming two dockwidgets together one above the other) and this can be done only if the first one is a dockwidget too.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDockWidget-title

    You can achieve the same kind of functionality with QSplitter, whose orientation is vertical, see QSplitter::setOrientation().
    J-P Nurmi

  5. #5
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QDockWidget-title

    QSplitter will not do the trick I need. I'm sure of that. I need QDockWidget. Is there any way to remove the title bar??

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDockWidget-title

    After taking a look at src/gui/widget/dockwidget.cpp, QDockWidgetPrivate::relayout(), I'm afraid it's not possible. The dock widget title bar is not a separate widget. The dockwidget's private layouting mechanism just reserves some space for the title.

    You can set dock widget's features to QDockWidget::NoDockWidgetFeatures to make buttons disappear. You can return return 0 for QStyle::pixelMetric(QStyle::PM_DockWidgetTitleMarg in) to make it thinner than normal. But it will still calculate some minimum height based on font metrics. You can even construct a font with point size 1 (font's point size must be greater than 0) to make the fontmetrics return smaller size, but the title will still appear...
    Last edited by jpn; 23rd August 2006 at 14:48. Reason: Disabled smilies
    J-P Nurmi

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDockWidget-title

    So, how does this differ from having dock widgets with no title bars?

    Qt Code:
    1. #include <QtGui>
    2.  
    3. class MainWindow: public QMainWindow
    4. {
    5. public:
    6. MainWindow(QWidget* parent = 0): QMainWindow(parent)
    7. {
    8. // just some 2 dummy example widgets to fill splitters with
    9. QListWidget* list = new QListWidget;
    10. for (int i = 0; i < 10; ++i)
    11. list->addItem(QString::number(i));
    12. QTableWidget* table = new QTableWidget(4, 1);
    13. for (int r = 0; r < table->rowCount(); ++r)
    14. for (int c = 0; c < table->columnCount(); ++c)
    15. table->setItem(r, c, new QTableWidgetItem(QString::number(r*c+1)));
    16. QLabel* label = new QLabel("central");
    17. label->setAlignment(Qt::AlignCenter);
    18.  
    19. QSplitter* h = new QSplitter(Qt::Horizontal);
    20. QSplitter* v = new QSplitter(Qt::Vertical);
    21. v->addWidget(list);
    22. v->addWidget(table);
    23. h->addWidget(v);
    24. h->addWidget(label);
    25. setCentralWidget(h);
    26. }
    27. };
    28.  
    29. int main(int argc, char *argv[])
    30. {
    31. QApplication a(argc, argv);
    32. MainWindow w;
    33. w.show();
    34. return a.exec();
    35. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  8. #8
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QDockWidget-title

    Thank you for all your help. I'll try using qsplitter and see if it's ql.

  9. #9
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QDockWidget-title

    Ok. Splitter isn't ql because I do need some of dockWidget's features. I don't need to remove the title bar anymore (I fixed this problem), but I don't know that if I can draw a dockwidgetHandle like QToolbarHandle ??? in my own Qstyle

  10. #10
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDockWidget-title

    Quote Originally Posted by moowy
    Ok. Splitter isn't ql because I do need some of dockWidget's features.
    We could be more helpful if you told us exactly what features do you need.

    I don't need to remove the title bar anymore (I fixed this problem), but I don't know that if I can draw a dockwidgetHandle like QToolbarHandle ??? in my own Qstyle
    Sure, you can draw anything you want with styles, you will just have to provide proper style options. See QStyle::draw*() docs. You will have to implement the behaviour yourself. Drawing a handle won't bring you any functionality..

    Are you aware that you can place any widget in a tool bar? Maybe this is more what you're after?
    Attached Images Attached Images
    J-P Nurmi

  11. #11
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QDockWidget-title

    Can you maybe help me with the apropriate PE_primitiveElement to use to draw onto QDockWidget titleBar or maybe CE_controlElement ??
    The handle is just for good looks .
    The features I need are float and movable dockwidget

  12. #12
    Join Date
    Apr 2014
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QDockWidget-title

    I got rid of the title bar in my DockWidget by setting it to an empty widget:

    Qt Code:
    1. QWidget* myTitle = new QWidget( this );
    2. myDock->setTitleBarWidget( myTitle );
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QDockWidget Size
    By kiker99 in forum Qt Programming
    Replies: 9
    Last Post: 31st March 2007, 17:15
  2. QDockWidget flicker
    By fellobo in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2006, 21:42
  3. QTableWidget -> QDockWidget,
    By ogre in forum Qt Programming
    Replies: 3
    Last Post: 26th January 2006, 07:51
  4. QDockWidget: Debugging crash
    By carsten in forum Qt Programming
    Replies: 10
    Last Post: 7th January 2006, 11:50

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.