Clickable places in QGraphicsSceen
-
hi,
i'm trying to make the element of my table tab[i] clickable and my text is moving "pivot glissant" and i can't do it
could someone help me pleasevoid View::createMetroTabBar()
{QGraphicsTextItem *tmp; QPropertyAnimation *anim; int xPos = componentMargin; QString tab[]={"Acceuil","Espace Etudiant", "Espace Encadrant","Administration"};
QString text;
// create 4 items for(int i = 0; i < itemCount; ++i) { tmp = new QGraphicsTextItem(); tmp->setAcceptHoverEvents(false); text = tab[i];//.append(QString("%1").arg(i + 1));
tmp->setPlainText(text);
tmp->setFont(headerFont); tmp->adjustSize(); tmp->setDefaultTextColor(uiTextColor); // below header text tmp->setPos(xPos, (componentMargin2 * 2.5 + bodyTextSize*2)); // calculate position for the next item. ComponentMargin + item width + ComponentMargin xPos = xPos + tmp->textWidth() + componentMargin2*3; anim = new QPropertyAnimation(tmp,"pos"); anim->setDuration(animationTime); anim->setPropertyName("pos"); anim->setEasingCurve(QEasingCurve::OutCirc); mGroupAnimHeader->addAnimation(anim); mHeaderAnimations.append(anim); // de-highlight other than first item if(i != 0) tmp->setOpacity(0.3); mHeaderItems.append(tmp); scene()->addItem(tmp); }
}
-
Hi,
Please enclose your code in coding tags, otherwise it's extremely hard to read and people won't be motived to read the code to help you