27 #include <QApplication>
31 #include <QMouseEvent>
32 #include <QStyleHints>
40 : QWidget(parent), _key(key), _value_idx(value_idx)
42 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
44 _layout =
new QHBoxLayout(
this);
45 _layout->setContentsMargins(0, 0, 0, 0);
46 _layout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
48 QLabel* label =
new QLabel(title);
49 _layout->addWidget(label);
52 SignalWidget::~SignalWidget() {}
54 QSize SignalWidget::sizeHint()
const {
return QSize(200, 15); }
56 void SignalWidget::mousePressEvent(QMouseEvent* event)
58 if (event->button() == Qt::LeftButton) _drag_start_position =
event->pos();
60 QWidget::mousePressEvent(event);
63 void SignalWidget::mouseMoveEvent(QMouseEvent* event)
65 if (!(event->buttons() & Qt::LeftButton))
return;
66 if ((event->pos() - _drag_start_position).manhattanLength() < QApplication::startDragDistance())
return;
69 QDrag* drag =
new QDrag(
this);
70 QMimeData* mime_data =
new QMimeData;
71 mime_data->setText(_key +
"::" + QString::number(_value_idx));
72 drag->setMimeData(mime_data);
74 Qt::DropAction drop_action = drag->exec();