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
// Private Classes are not visible by including <QMainWindow>, so this is required. check the path on you platform
#include "../../src/gui/widgets/qmainwindowlayout_p.h"
{
public:
setPalette(palette);
}
protected:
option.initFrom( this );
painter.
drawControl(QStyle::CE_FocusFrame, option
);
}
};
MainWindow
::MainWindow(QWidget *parent
) : Ui::MainWindow()
{
setupUi(this);
...
QMainWindowLayout * main_layout = dynamic_cast<QMainWindowLayout *>(layout());
if(main_layout)
{
delete main_layout->gapIndicator; //gapIndicator is QRubberBand, just delete it and replace it your rubber band
main_layout
->gapIndicator
= new MyRubberBand
(QRubberBand::Rectangle,
this);
}
...
}
// Private Classes are not visible by including <QMainWindow>, so this is required. check the path on you platform
#include "../../src/gui/widgets/qmainwindowlayout_p.h"
class MyRubberBand : public QRubberBand
{
public:
MyRubberBand(Shape s, QWidget * p = 0) : QRubberBand( s, p ) {
QPalette palette;
palette.setBrush( QPalette::WindowText, QBrush( Qt::red ) );
setPalette(palette);
}
protected:
virtual void paintEvent( QPaintEvent * ) {
QStylePainter painter(this);
QStyleOptionFocusRect option;
option.initFrom( this );
painter.drawControl(QStyle::CE_FocusFrame, option);
}
};
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
Ui::MainWindow()
{
setupUi(this);
...
QMainWindowLayout * main_layout = dynamic_cast<QMainWindowLayout *>(layout());
if(main_layout)
{
delete main_layout->gapIndicator; //gapIndicator is QRubberBand, just delete it and replace it your rubber band
main_layout->gapIndicator = new MyRubberBand(QRubberBand::Rectangle, this);
}
...
}
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
Bookmarks