feat: round corners
This commit is contained in:
@@ -16,6 +16,7 @@ Network::Network(QWidget* parent)
|
|||||||
mainLayout_ = new QVBoxLayout(parent);
|
mainLayout_ = new QVBoxLayout(parent);
|
||||||
mainLayout_->setContentsMargins(0,0,0,0);
|
mainLayout_->setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
|
|
||||||
this->setLayout(mainLayout_);
|
this->setLayout(mainLayout_);
|
||||||
|
|
||||||
|
|
||||||
@@ -55,6 +56,15 @@ Network::Network(QWidget* parent)
|
|||||||
|
|
||||||
|
|
||||||
mainLayout_->addWidget(view_);
|
mainLayout_->addWidget(view_);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Network::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
|
QPainterPath path;
|
||||||
|
path.addRoundedRect(this->rect(), 15, 15);
|
||||||
|
QRegion region = QRegion(path.toFillPolygon().toPolygon());
|
||||||
|
this->setMask(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Network::leftMousePress(QMouseEvent *event)
|
void Network::leftMousePress(QMouseEvent *event)
|
||||||
|
|||||||
@@ -25,4 +25,5 @@ private:
|
|||||||
void destroyFloatingEdge();
|
void destroyFloatingEdge();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <QGraphicsSceneWheelEvent>
|
#include <QGraphicsSceneWheelEvent>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <qgraphicsview.h>
|
#include <qgraphicsview.h>
|
||||||
|
#include <QPainterPath>
|
||||||
|
|
||||||
NetworkGraphicsScene::NetworkGraphicsScene()
|
NetworkGraphicsScene::NetworkGraphicsScene()
|
||||||
: QGraphicsScene()
|
: QGraphicsScene()
|
||||||
@@ -18,9 +19,15 @@ NetworkGraphicsScene::NetworkGraphicsScene()
|
|||||||
|
|
||||||
void NetworkGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
|
void NetworkGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// QPainterPath path;
|
||||||
|
// path.addRoundedRect(rect, 15, 15);
|
||||||
|
// painter->setClipPath(path);
|
||||||
|
|
||||||
QGraphicsScene::drawBackground(painter, rect);
|
QGraphicsScene::drawBackground(painter, rect);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int top = ceil(rect.top());
|
int top = ceil(rect.top());
|
||||||
int bottom = floor(rect.bottom());
|
int bottom = floor(rect.bottom());
|
||||||
int left = floor(rect.left());
|
int left = floor(rect.left());
|
||||||
|
|||||||
Reference in New Issue
Block a user