Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Clickable places in QGraphicsSceen

Clickable places in QGraphicsSceen

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 851 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    youyou
    wrote on last edited by
    #1

    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 please

    void 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);
    
    
    
    
    
    }
    

    }

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved