Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Bug? - Moving QFrame - not working when setVisible(false)
Forum Updated to NodeBB v4.3 + New Features

Bug? - Moving QFrame - not working when setVisible(false)

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 1.6k 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.
  • M Offline
    M Offline
    maximus
    wrote on last edited by
    #1

    I have this code that move a QFrame and show it (working) :

    @ frameAchievement->setVisible(true);
    QPoint currentPoint = frameAchievement->pos();
    frameAchievement->setProperty("pos", QPoint(currentPoint.x()-250, currentPoint.y()));
    qDebug() << "FRAME IS NOW AT " << frameAchievement->pos();@

    This one doesn't work (widget position is not moved on screen, allthought it printed the correct coordinate on the log) :

    @ QPoint currentPoint = frameAchievement->pos();
    frameAchievement->setProperty("pos", QPoint(currentPoint.x()-250, currentPoint.y()));
    frameAchievement->setVisible(true);
    qDebug() << "FRAME IS NOW AT " << frameAchievement->pos();@

    I need to set visible my Widget after moving it, or it cause a flashing widget on screen for a brief moment, and I don't want that effect.

    So the bug would be, changing the "pos" property is not working when QWidget is not visible.

    Thank you


    Free Indoor Cycling Software - https://maximumtrainer.com

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maximus
      wrote on last edited by
      #2

      Here is the full code for anyone interested, still haven't figured why I can't move my QFrame...

      @void WorkoutDialog::animateAchievement() {

      achievementCurrentlyPlaying = true;
      
      ///Take achievement from top of queue
      Achievement *achievement = queueAchievement.head();
      /// change name and icon (64x64)
      labelAchievementName->setText(achievement->getName());
      labelIcon->setStyleSheet("image: url(" + achievement->getIconPath() + ")");
      
      
      if (firstTimePlayAchievement) {
          ///TOFIX: widget flash for a second when first appearing
          frameAchievement->setVisible(true);
          QPoint currentPoint = frameAchievement->pos();
          frameAchievement->setProperty("pos", QPoint(currentPoint.x()-250, currentPoint.y()));
      }
      
      qDebug() << "FRAME IS NOW AT " <&lt; frameAchievement-&gt;pos();
      
      
      QPoint currentPoint = frameAchievement->pos();
      QPoint bottomRightBeforeAnim = QPoint(currentPoint.x(), currentPoint.y());
      QPoint bottomRightAftereAnim = QPoint(bottomRightBeforeAnim.x()+250, bottomRightBeforeAnim.y());
      
      QPropertyAnimation *animationShow = new QPropertyAnimation(frameAchievement, "pos");
      animationShow->setDuration(1500);
      animationShow->setStartValue(bottomRightBeforeAnim) ;
      animationShow->setEndValue(bottomRightAftereAnim) ;
      animationShow->start(QAbstractAnimation::DeleteWhenStopped);
      
      
      firstTimePlayAchievement = false;
      timerRemoveAnimation->start(5000);
      

      }@


      Free Indoor Cycling Software - https://maximumtrainer.com

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maximus
        wrote on last edited by
        #3

        How my QFrame is created :

        @ //// ---------------------- Test Achievement Window --------------------------
        frameAchievement = new QFrame(ui->widget_allSpeedo);
        frameAchievement->setAttribute(Qt::WA_TransparentForMouseEvents,true);
        frameAchievement->setFocusPolicy(Qt::NoFocus);
        frameAchievement->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        frameAchievement->setFixedSize(250, 150);
        frameAchievement->setObjectName("frameAchievement");
        frameAchievement->setStyleSheet("QFrame#frameAchievement { background-color : rgba(1,1,1,240); "
        "border: 4px solid gray; }"
        "QLabel { color: white; }");

        QGridLayout *gridAchievement = new QGridLayout(frameAchievement);
        
        QFont fontBold;
        fontBold.setPointSize(10);
        fontBold.setBold(true);
        
        labelIcon = new QLabel(frameAchievement);
        labelIcon->setMinimumHeight(64);
        labelIcon->setMaximumHeight(64);
        labelIcon->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
        labelIcon->setObjectName("labelIcon");
        labelIcon->setStyleSheet("image: url(:/image/icon/trophy)");
        
        QLabel *labelAchievementReceived = new QLabel(frameAchievement);
        labelAchievementReceived->setMinimumHeight(20);
        labelAchievementReceived->setMaximumHeight(20);
        labelAchievementReceived->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
        labelAchievementReceived->setAlignment(Qt::AlignBottom | Qt::AlignRight);
        labelAchievementReceived->setAttribute(Qt::WA_TransparentForMouseEvents,true);
        labelAchievementReceived->setText(tr("New Achievement!"));
        labelAchievementReceived->setFont(fontBold);
        
        labelAchievementName = new QLabel(frameAchievement);
        labelAchievementName->setMinimumHeight(20);
        labelAchievementName->setMaximumHeight(20);
        labelAchievementName->setMaximumWidth(400);
        labelAchievementName->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
        labelAchievementName->setAlignment(Qt::AlignBottom | Qt::AlignRight);
        labelAchievementName->setAttribute(Qt::WA_TransparentForMouseEvents,true);
        labelAchievementName->setText(tr("Name here!"));
        labelAchievementName->setFont(fontBold);
        
        
        gridAchievement->addWidget(labelIcon, 0, 0, 2, 1);
        gridAchievement->addWidget(labelAchievementReceived, 0, 1);
        gridAchievement->addWidget(labelAchievementName, 1, 1);
        
        
        QGridLayout *glayout = static_cast<QGridLayout*>( ui->widget_allSpeedo->layout()  );
        glayout->addWidget(frameAchievement, 0, 0, 0, 0);
        
        frameAchievement->setAttribute(Qt::WA_TransparentForMouseEvents,true);
        
        
        timerRemoveAnimation = new QTimer(this);
        timerAnimationCompleted = new QTimer(this);
        connect (timerRemoveAnimation, SIGNAL(timeout()), this, SLOT(removeAchievementAnimation()) );
        connect (timerAnimationCompleted, SIGNAL(timeout()), this, SLOT(lastAchievementAnimationDone()) );
        achievementCurrentlyPlaying = false;
        firstTimePlayAchievement = true;
        /// Hide achievement window /// Not working to move position manually here..
        //    frameAchievement->setVisible(true);
        //    QPoint currentPoint = frameAchievement->pos();
        //    frameAchievement->setProperty("pos", QPoint(currentPoint.x()-250, currentPoint.y()));
        frameAchievement->setVisible(false);
        

        @


        Free Indoor Cycling Software - https://maximumtrainer.com

        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