57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
#include <QGraphicsGridLayout>
|
|
#include <QLabel>
|
|
#include <QGraphicsProxyWidget>
|
|
#include <QLineEdit>
|
|
#include <QComboBox>
|
|
#include <QPainter>
|
|
#include <QSizePolicy>
|
|
#include "diagramEditor/editItem.h"
|
|
|
|
EditItem::EditItem(QGraphicsItem *parent)
|
|
: QGraphicsWidget(parent)
|
|
{
|
|
_layout = new QGraphicsGridLayout(this);
|
|
setupUI();
|
|
}
|
|
EditItem::~EditItem()
|
|
{
|
|
|
|
}
|
|
|
|
void EditItem::setupUI()
|
|
{
|
|
QLabel* pName = new QLabel("名称");
|
|
QGraphicsProxyWidget* proLabelName = new QGraphicsProxyWidget;
|
|
proLabelName->setWidget(pName);
|
|
_layout->addItem(proLabelName,0,0);
|
|
|
|
QGraphicsProxyWidget* proLeName = new QGraphicsProxyWidget;
|
|
_EditorName = new QLineEdit();
|
|
proLeName->setWidget(_EditorName);
|
|
_layout->addItem(proLeName,0,1);
|
|
|
|
QLabel* pType = new QLabel("类型");
|
|
QGraphicsProxyWidget* proLabelType = new QGraphicsProxyWidget;
|
|
proLabelType->setWidget(pType);
|
|
_layout->addItem(proLabelType,1,0);
|
|
|
|
QGraphicsProxyWidget* proComboType = new QGraphicsProxyWidget;
|
|
_ComboType = new QComboBox();
|
|
proComboType->setWidget(_ComboType);
|
|
_layout->addItem(proComboType,1,1);
|
|
|
|
//_layout->setSpacing(0);
|
|
//_layout->setSizePolicy(QSizePolicy());
|
|
}
|
|
|
|
void EditItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
|
{
|
|
painter->fillRect(boundingRect(), QColor(224, 238, 238)); // 背景
|
|
painter->drawRect(boundingRect());
|
|
}
|
|
|
|
void EditItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
|
{
|
|
int a = 1;
|
|
}
|