Results 1 to 5 of 5

Thread: QDockWidget, QCleanlooksStyle and QWindowsVistaStyle

  1. #1
    Join Date
    Jun 2011
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default QDockWidget, QCleanlooksStyle and QWindowsVistaStyle

    Hi.

    I have a MainWindow with some QDockWidgets, nothing special.
    I'm applying to the entire QApplication a style sub-classed from QCleanlooksStyle just for changing some features like icon sizes and stuff...

    However I've noticed that QDockArea "hightlights" (with a blue color) when QDockWidget are near to be placed with QWindowsVistaStyle or QWindowsXPStyle... With any other style the "hightlight" just consists of a dotted frame instead of a colored frame...I don't know how to implement that kind of "highlighting" with any other style like QCleanlooksStyle or QPlastiqueStyle... If anyone knows how to do it I would appreciate that give me some directions to do that...

    I suppose that is something maybe with styleSheet or styles or mousemoveevent or something... maybe easier...

    Below you'll find what is the difference and what I'm talking about...

    Thanks and sorry for my english...
    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QDockWidget, QCleanlooksStyle and QWindowsVistaStyle

    It may not be possible, as QDockWidget supports styling of the title bar and the title bar buttons when docked.

    Also the Documentation says
    Quote Originally Posted by Qt Documentation
    The style sheet has no effect when the QDockWidget is undocked as Qt uses native top level windows when undocked

  3. #3
    Join Date
    Jun 2011
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDockWidget, QCleanlooksStyle and QWindowsVistaStyle

    Thanks for the reply Santosh.

    I know that only QDockWidget's title bar and title bar buttons are customizable but I think that this is more something about the QDockArea than QDockWidget indeed and also I know that the window containing a QDockWidget is a native operating system window. I don't know if someone knows a "Qt Troll" or one of the Qt developers who maybe knows about this kind of topics because I think this is more about setting up the subclassed style than the operating system...

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QDockWidget, QCleanlooksStyle and QWindowsVistaStyle

    Ok daleotar, here is something which I can say, It is possible to change the color of the QDockArea "hightlights" to what every you want, but still I don't think it is possible using style sheets (not directly)

    One of the ways to do it is, by sub-classing and implementing the same behavior irrespective of style, hmm.. wait a minute, may be you can try sub-classing and apply style sheet on the sub-class, or what ever you like, but here is how to do it.

    QMainWindow has internal layout which manages all the QToolBar, QDockWidgets etc in the main window, and allow the user to move around and play with layout. So during the moving of the layout widgets, the main window layout (i.e. QMainWindowLayout, which is private to QMainWindow), uses QRubberBand to highlight the allowed docking region.

    So what you can do is, replace the QRubberBand with a custom MyRubberBand, and do what ever you want in custom MyRubberBand. This may not be straight forward, as you need to access a QMainWindow's private variable, but I can suggest a way to do so, here it is


    Qt Code:
    1. // Private Classes are not visible by including <QMainWindow>, so this is required. check the path on you platform
    2. #include "../../src/gui/widgets/qmainwindowlayout_p.h"
    3.  
    4. class MyRubberBand : public QRubberBand
    5. {
    6. public:
    7. MyRubberBand(Shape s, QWidget * p = 0) : QRubberBand( s, p ) {
    8. QPalette palette;
    9. palette.setBrush( QPalette::WindowText, QBrush( Qt::red ) );
    10. setPalette(palette);
    11. }
    12.  
    13. protected:
    14. virtual void paintEvent( QPaintEvent * ) {
    15. QStylePainter painter(this);
    16.  
    17. option.initFrom( this );
    18.  
    19. painter.drawControl(QStyle::CE_FocusFrame, option);
    20. }
    21. };
    22.  
    23. MainWindow::MainWindow(QWidget *parent) :
    24. QMainWindow(parent),
    25. Ui::MainWindow()
    26. {
    27. setupUi(this);
    28. ...
    29. QMainWindowLayout * main_layout = dynamic_cast<QMainWindowLayout *>(layout());
    30. if(main_layout)
    31. {
    32. delete main_layout->gapIndicator; //gapIndicator is QRubberBand, just delete it and replace it your rubber band
    33. main_layout->gapIndicator = new MyRubberBand(QRubberBand::Rectangle, this);
    34. }
    35. ...
    36. }
    To copy to clipboard, switch view to plain text mode 


    Also refer this post for QRubberBand style
    http://www.qtcentre.org/threads/2132...with-red-color

  5. #5
    Join Date
    Jun 2011
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDockWidget, QCleanlooksStyle and QWindowsVistaStyle

    Thanks Santosh, It was really helpful. As soon as I got it working I'll post it just for information of the other users

Similar Threads

  1. Replies: 1
    Last Post: 7th December 2010, 21:46
  2. Help with QDockWidget
    By mindbender in forum Qt Programming
    Replies: 6
    Last Post: 10th March 2010, 16:13
  3. QDockwidget
    By peace_comp in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 05:19
  4. QDockWidget
    By fellobo in forum Qt Programming
    Replies: 8
    Last Post: 26th June 2008, 18:52
  5. QDockWidget's
    By tanminh in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2008, 23:33

Tags for this Thread

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.