Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Solved Errors in EventLogger. This eventlogger is designed on Qt5 but having these errors in QT 6.2

    General and Desktop
    6
    13
    149
    Loading More Posts
    • 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.
    • Aviral 0
      Aviral 0 @Christian Ehrlicher last edited by

      @Christian-Ehrlicher I have solved the problem of QTime with QElapsedTimer
      But I can't find replacement of QPixmap. Please if you can find share.

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @Aviral 0 last edited by

        @Aviral-0 From the link @Christian-Ehrlicher gave you:

        QPixmap QPixmap::grabWidget(QObject *widget, const QRect &rectangle)
        
        This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
        
        Use QWidget::grab() instead.
        

        So, what about using grab() instead of grabWidget()?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Aviral 0 2 Replies Last reply Reply Quote 1
        • Aviral 0
          Aviral 0 @jsulm last edited by

          @jsulm Yeah I am trying it, and its throwing error saying
          call to non static member function without an object argument
          If you know what change its aking?

          Christian Ehrlicher 1 Reply Last reply Reply Quote 0
          • Christian Ehrlicher
            Christian Ehrlicher Lifetime Qt Champion @Aviral 0 last edited by

            @Aviral-0 said in Errors in EventLogger. This eventlogger is designed on Qt5 but having these errors in QT 6.2:

            all to non static member function without an object argument

            Because QWidget::grab() is not a static function. You have to call it on an object (mainWidget I would guess) - plain c++ stuff.

            Qt has to stay free or it will die.

            1 Reply Last reply Reply Quote 1
            • Aviral 0
              Aviral 0 @jsulm last edited by Aviral 0

              @jsulm I have done this, please suggest where I am wrong:

               if (this->screenshotsEnabled && eventType.compare("MouseMove") != 0)
                {
                  QPixmap *gb;
                  gb mainWidget->grab().toImage().save(screenshotDirName + "/" + QString::number(elapsedTime) + ".png", "PNG");
              }
              

              Its showing error, Please Help!

              C 1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                Hi,

                You are missing an = sign.

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

                Aviral 0 1 Reply Last reply Reply Quote 0
                • Aviral 0
                  Aviral 0 @SGaist last edited by

                  @SGaist with = also its showing error

                  SGaist 1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion @Aviral 0 last edited by

                    @Aviral-0 said in Errors in EventLogger. This eventlogger is designed on Qt5 but having these errors in QT 6.2:

                    @SGaist with = also its showing error

                    You do realise that "showing error" gives no information to help you with ?

                    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 Reply Quote 1
                    • C
                      ChrisW67 @Aviral 0 last edited by

                      @Aviral-0 said in Errors in EventLogger. This eventlogger is designed on Qt5 but having these errors in QT 6.2:

                      if (this->screenshotsEnabled && eventType.compare("MouseMove") != 0)
                      {
                      QPixmap *gb;
                      gb mainWidget->grab().toImage().save(screenshotDirName + "/" + QString::number(elapsedTime) + ".png", "PNG");
                      }

                      Its showing error, Please Help!
                      

                      As @SGaist points out, you are missing a "=".

                      You are also not initialising your pointer (a C++ cardinal sin) but ultimately that's a moot point.
                      QWidget::grab() returns an actual QPixmap, not a pointer to one.
                      There is also no need to convert the QPixmap to a QImage in order to save it: QPixmap::save().

                       if (this->screenshotsEnabled && eventType.compare("MouseMove") != 0)
                       {
                          QPixmap gb = mainWidget->grab();
                          gb.save(screenshotDirName + "/" + QString::number(elapsedTime) + ".png", "PNG");\
                          // Consider whether you need to check that the save was successful
                      }
                      
                      1 Reply Last reply Reply Quote 2
                      • A
                        AlmaCarreon Banned last edited by AlmaCarreon

                        This post is deleted!
                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post