Results 1 to 19 of 19

Thread: QDockWidget-title

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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
    Somehow this doesn't do the trick. I already have installed an eventFilter(paint event) on the qdockwidget and I applied the code to it but it doesn't show. Any other ideas??
    Painting in an event filter is a bit problematic because the event goes FIRST through the filter and THEN to the base class (assuming that the event filter doesn't filter it out). So basically the base class draws over anything you had drawn in the event filter. This kind of painting is possible in event filter only by doing some ugly tricks. Basically you have to deliver the event to the receiver widget by hand and then do the custom painting afterwards. And you will also have to temporarily remove the event filter to avoid an infinite loop.

    Qt Code:
    1. // this is inside an event filter where event type is a paint event..
    2.  
    3. // remove the event filter during sending
    4. // the paint event to avoid an infinite loop
    5. widget->removeEventFilter(this);
    6.  
    7. // send the event and let the widget to draw itself first
    8. QApplication::sendEvent(widget, event);
    9.  
    10. // restore the event filter
    11. widget->installEventFilter(this);
    12.  
    13. // draw your custom things here
    14. QStylePainter painter(widget);
    15. ....
    16.  
    17. // be sure to return true so that the widget doesn't
    18. // receive this paint event and paint itself over again
    19. return true;
    To copy to clipboard, switch view to plain text mode 

    So, I recommend you to simply subclass QDockWidget and override paintEvent()... it will be much simplier and less error prone..
    J-P Nurmi

  2. #2
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QDockWidget-title

    I have another problem conserning QDockWidget. In my workspace i have tvo dockwidgets and one other widget. The problem is that these two widgets have their own PE_IndicatorDockWidgetResizeHandle and I only need one. I know how to disable them both but i don't know how to disable just one.

    i tried this code but it doesn't work (if i remove the part with the objectName it disables the both of them)

    if (((widget->inherits("QDockWidgetSeparator")) || (widget->inherits("QDockSeparator"))) && (widget->objectName()=="name"))
    {
    widget->setAttribute(Qt::WA_Disabled);
    }

  3. #3
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QDockWidget-title

    Could you maybe tell me how could I get from only a Qwidget his orientation : QStyle::State_Horizontal ????

    Ok. let me be more clear:

    I have a qmainwindow and in it 2 dockwidgets(left,bottom) and a qworkspace.
    the problem is that the left one draws QDockSeparator on the right and on the bottom at his borders. I only want him to draw the QDockSeparator on the bottom border. How could I achieve this???

    please help.
    Last edited by moowy; 28th August 2006 at 10:34.

  4. #4
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QDockWidget-title

    Does anyone know how can i fix this?

  5. #5
    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
    I have a qmainwindow and in it 2 dockwidgets(left,bottom) and a qworkspace.
    the problem is that the left one draws QDockSeparator on the right and on the bottom at his borders. I only want him to draw the QDockSeparator on the bottom border. How could I achieve this???
    QDockSeparators are created/shown/hidden on the fly when needed. You cannot delete them or a crash will occur. You will have to monitor for every movement and possibly resize events too, and hide the separator again and again by hand when appropriate.

    You can find the QDockSeparators like this:
    Qt Code:
    1. // Notice this (from qdockseparator_p.h):
    2.  
    3. //
    4. // W A R N I N G
    5. // -------------
    6. //
    7. // This file is not part of the Qt API. It exists purely as an
    8. // implementation detail. This header file may change from version to
    9. // version without notice, or even be removed.
    10. //
    11. // We mean it.
    12. //
    13. #include <private/qdockseparator_p.h>
    14. ...
    15. // notice that QDockSeparators are children of QMainWindow, not children of QDockWidget
    16. foreach (QObject* obj, children())
    17. {
    18. if (QString(obj->metaObject()->className()) == "QDockSeparator")
    19. {
    20. QDockSeparator* sep = qobject_cast<QDockSeparator*>(obj);
    21. if (sep && sep->orientation == Qt::Vertical)
    22. {
    23. ...
    24. }
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. QDockWidget Size
    By kiker99 in forum Qt Programming
    Replies: 9
    Last Post: 31st March 2007, 16:15
  2. QDockWidget flicker
    By fellobo in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2006, 20:42
  3. QTableWidget -> QDockWidget,
    By ogre in forum Qt Programming
    Replies: 3
    Last Post: 26th January 2006, 06:51
  4. QDockWidget: Debugging crash
    By carsten in forum Qt Programming
    Replies: 10
    Last Post: 7th January 2006, 10: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.