Hi,
On 13-06-2018 09:26, Nicolas Krieger wrote:
I would like to have a border in my widget, just like a QFrame. But a
QFrame which border is over and not beside. I want to hide and show the
border, but without layout re-sizing effects.
If I understand your problem correctly, you should be able to use a
QGraphicsEffect like this:
#include <QGraphicsEffect>
#include <QPainter>
class InsideBorderGraphicsEffect : public QGraphicsEffect
{
Q_OBJECT
public:
InsideBorderGraphicsEffect(QObject* parent = nullptr)
: QGraphicsEffect(parent)
{
}
protected:
void draw(QPainter* painter) override
{
QPoint offset;
const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates,
&offset);
painter->drawPixmap(offset, pixmap);
painter->setPen(QPen(Qt::magenta, 10));
painter->drawRect(boundingRect());
}
};
Now it is just a matter of setting the effect on your widget with
setGraphicsEffect(new InsideBorderGraphicsEffect);
and clear it again with
setGraphicsEffect(nullptr);
--
Frederik Christiani
Viking Software
https://www.vikingsoftware.com/
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest