修改的代码如下,主要想用textedit来输入
void DiagramView::contentsMouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() == LeftButton && activeItem
&& activeItem->rtti() == DiagramBox::RTTI) {
DiagramBox *box = (DiagramBox *)activeItem;
bool ok;
QString newText = QInputDialog::getText(
tr("Diagram"), tr("Enter new text:"),
QTextEdit::Default, //主要想改这句 box->text(), &ok, this);
if (ok) {
box->setText(newText);
canvas()->update();
}
}
}
总程序在附件里面