-1
我想知道我們可以使用從一個窗口到另一個窗口的ID按鈕的方式。來自另一個窗口的Id按鈕
例如,我想從窗口對話框中獲得一個文本,點擊確定按鈕後創建一個窗口對話框?
我試過一個信號,從一個groupbutton獲得id按鈕,我也試着創建一個布爾變量,當ok按鈕被點擊但沒有任何效果時,需要true
。
bool Dialog2::getIdok()
{
//qDebug() << "c'est id" << gb->id(b1) << "qui a été cliqué";
if(gb->id(b1))
return true;
}
它包含了我想要改變的DrawText的arrow.cpp漆事件:
void Arrow::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget *)
{
if (myStartItem->collidesWithItem(myEndItem))
return;
QPen myPen = pen();
myPen.setColor(myColor);
qreal arrowSize = 20;
painter->setPen(myPen);
painter->setBrush(myColor);
QLineF centerLine(myStartItem->pos(), myEndItem->pos());
QPolygonF endPolygon = myEndItem->polygon();
QPointF p1 = endPolygon.first() + myEndItem->pos();
QPointF p2;
QPointF intersectPoint;
QLineF polyLine;
for (int i = 1; i < endPolygon.count(); ++i)
{
p2 = endPolygon.at(i) + myEndItem->pos();
polyLine = QLineF(p1, p2);
QLineF::IntersectType intersectType = polyLine.intersect(centerLine, &intersectPoint);
if (intersectType == QLineF::BoundedIntersection)
break;
p1 = p2;
}
setLine(QLineF(intersectPoint, myStartItem->pos()));
double angle = ::acos(line().dx()/line().length());
if (line().dy() >= 0)
angle = (Pi * 2) - angle;
QPointF arrowP1 = line().p1() +
QPointF(sin(angle + Pi/3) * arrowSize,
cos(angle + Pi/3) * arrowSize);
QPointF arrowP2 = line().p1() +
QPointF(sin(angle + Pi - Pi/3) * arrowSize,
cos(angle + Pi - Pi/3) * arrowSize);
QPolygonF startPolygon = myStartItem->polygon();
QPointF p3 = startPolygon.first() +
myStartItem->pos() -
QPointF(sin(angle + Pi/2) * arrowSize,
cos(angle + Pi/2) * arrowSize);
arrowHead.clear();
arrowHead << line().p1() << arrowP1 << arrowP2;
painter->drawLine(line());
painter->drawText(p3,m1);
painter->drawText(arrowP2,m2);
if (isSelected())
{
painter->setPen(QPen(myColor, 1, Qt::DashLine));
QLineF myLine = line();
myLine.translate(0, 4.0);
painter->drawLine(myLine);
myLine.translate(0,-8.0);
painter->drawLine(myLine);
}
}
,我已經創建了包含取1時,我就OK點擊一個int變量對話框類按鈕,並在箭頭上課的時候我雙短聲的對話框中顯示出來,但是當我點擊確定按鈕沒有happen.Here是doubleclickmouse事件方法:
void Arrow::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
if (mouseEvent->button() != Qt::LeftButton)
return;
mydiag = new Dialog2();
mydiag->show();
if(mydiag->cc==1)
{
m1 = mydiag->getvalue1();
m2 = mydiag->getvalue2();
}
}
請澄清什麼是你的目標。如果您在點擊確定後只需從窗口對話框中獲取文本,則不需要任何ID。另請說明你的對話是否是模態的,它們是如何相互關聯的。 – demonplus
我想知道的是如何從對話框類的組合框中獲取文本以在另一個窗口中使用它。 –
你可以把組合框中的文本放入類變量嗎?你能從其他窗口訪問這個變量的屬性嗎? – demonplus