Solved Errors in EventLogger. This eventlogger is designed on Qt5 but having these errors in QT 6.2
-
@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.
-
@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. -
@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()?
-
@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? -
@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.
-
@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!
-
Hi,
You are missing an = sign.
-
@SGaist with = also its showing error
-
@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 ?
-
@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 }
-
This post is deleted!