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. Errors in EventLogger. This eventlogger is designed on Qt5 but having these errors in QT 6.2
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 6 Posters 740 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.
  • C Christian Ehrlicher
    1 Feb 2023, 13:18

    See the deprecation information about those functions in Qt5, e.g. https://doc.qt.io/qt-5/qtime-obsolete.html and https://doc.qt.io/qt-5/qpixmap-obsolete.html

    To measure a timespan, use QElapsedTimer, for QPixmap see the deprecated function page.

    A Offline
    A Offline
    Aviral 0
    wrote on 1 Feb 2023, 13:23 last edited by
    #3

    @Christian-Ehrlicher Hi Thankyou for solution. I am new to QT, I have very little idea of how to do it. I would really appreciate if you help me with that piece of code! Thankyou and congrats for life time QT champion.

    1 Reply Last reply
    0
    • C Christian Ehrlicher
      1 Feb 2023, 13:18

      See the deprecation information about those functions in Qt5, e.g. https://doc.qt.io/qt-5/qtime-obsolete.html and https://doc.qt.io/qt-5/qpixmap-obsolete.html

      To measure a timespan, use QElapsedTimer, for QPixmap see the deprecated function page.

      A Offline
      A Offline
      Aviral 0
      wrote on 1 Feb 2023, 13:44 last edited by
      #4

      @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.

      J 1 Reply Last reply 1 Feb 2023, 13:45
      0
      • A Aviral 0
        1 Feb 2023, 13:44

        @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.

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 1 Feb 2023, 13:45 last edited by
        #5

        @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

        A 2 Replies Last reply 1 Feb 2023, 13:57
        1
        • J jsulm
          1 Feb 2023, 13:45

          @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()?

          A Offline
          A Offline
          Aviral 0
          wrote on 1 Feb 2023, 13:57 last edited by
          #6

          @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?

          C 1 Reply Last reply 1 Feb 2023, 14:00
          0
          • A Aviral 0
            1 Feb 2023, 13:57

            @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?

            C Online
            C Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 1 Feb 2023, 14:00 last edited by
            #7

            @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 Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1
            • J jsulm
              1 Feb 2023, 13:45

              @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()?

              A Offline
              A Offline
              Aviral 0
              wrote on 1 Feb 2023, 18:38 last edited by Aviral 0 2 Jan 2023, 18:41
              #8

              @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 1 Feb 2023, 23:10
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 1 Feb 2023, 18:48 last edited by
                #9

                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

                A 1 Reply Last reply 1 Feb 2023, 19:38
                0
                • S SGaist
                  1 Feb 2023, 18:48

                  Hi,

                  You are missing an = sign.

                  A Offline
                  A Offline
                  Aviral 0
                  wrote on 1 Feb 2023, 19:38 last edited by
                  #10

                  @SGaist with = also its showing error

                  S 1 Reply Last reply 1 Feb 2023, 19:45
                  0
                  • A Aviral 0
                    1 Feb 2023, 19:38

                    @SGaist with = also its showing error

                    S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 1 Feb 2023, 19:45 last edited by
                    #11

                    @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
                    1
                    • A Aviral 0
                      1 Feb 2023, 18:38

                      @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 Offline
                      C Offline
                      ChrisW67
                      wrote on 1 Feb 2023, 23:10 last edited by
                      #12

                      @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
                      2
                      • A Offline
                        A Offline
                        AlmaCarreon
                        Banned
                        wrote on 2 Feb 2023, 06:02 last edited by AlmaCarreon 2 Feb 2023, 06:03
                        #13
                        This post is deleted!
                        1 Reply Last reply
                        0

                        12/13

                        1 Feb 2023, 23:10

                        • Login

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