Is there a way to take screenshot of a window in pyqt5 or qt5?

Ref: http://doc.qt.io/qt-5/qscreen.html#grabWindow You say you require a screenshot of a window, therefore screenshot = screen.grabWindow(0, 0, 0, 100, 100) is not the appropriate call here, since it captures the entire screen, cropped according to the final 4 parameters. (the 100 parameters are width and height). screenshot = screen.grabWindow( widget.winId() ) captures the widget window. However, … Read more

QMYSQL driver available but not loaded

We should check our driver first $ cd /opt/Qt5.2.1/5.2.1/gcc_64/plugins/sqldrivers then we can find some files Use the command below to check library $ ldd libqsqlmysql.so if you find the problem libmysqlclient_r.so.16 => not found it may be the library-dependency problem. After I did a little research on the Internet, there is a way would be … Read more

How to create/read/write JSON files in Qt5

Example: Read json from file /* test.json */ { “appDesc”: { “description”: “SomeDescription”, “message”: “SomeMessage” }, “appName”: { “description”: “Home”, “message”: “Welcome”, “imp”:[“awesome”,”best”,”good”] } } void readJson() { QString val; QFile file; file.setFileName(“test.json”); file.open(QIODevice::ReadOnly | QIODevice::Text); val = file.readAll(); file.close(); qWarning() << val; QJsonDocument d = QJsonDocument::fromJson(val.toUtf8()); QJsonObject sett2 = d.object(); QJsonValue value = sett2.value(QString(“appName”)); … Read more

Get HWND on windows with Qt5 (from WId)

In Qt5 winEvent was replaced by nativeEvent: bool winEvent(MSG* pMsg, long* result) is now bool nativeEvent(const QByteArray & eventType, void * message, long *result) And in EcWin7::winEvent you have to cast void to MSG: bool EcWin7::winEvent(void * message, long * result) { MSG* msg = reinterpret_cast<MSG*>(message); if (msg->message == mTaskbarMessageId) { … I was able … Read more