kandi X-RAY | qt-solutions Summary
kandi X-RAY | qt-solutions Summary
qt-solutions
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of qt-solutions
qt-solutions Key Features
qt-solutions Examples and Code Snippets
Community Discussions
Trending Discussions on qt-solutions
QUESTION
The use case is a 2D map with a vehicle at the origin. The map shall also be translated in case the vehicle moves e.g. 0.5 pixels. I believe this should be feasible using bilinear interpolation or similar.
If there is no simple solution using Qt, I would appreciate hints to non-Qt-solutions.
Minimal example:
...ANSWER
Answered 2018-Sep-17 at 11:09I tested openCV and its function cv::warpAffine allows translation with sub-pixel precision (see MWE below).
After founding some old, unanswered threads on qtcentre.org, it seems to me that Qt simply does not allow translation with sub-pixel precision. Please correct me if I am wrong.
For Qt, I only found workarounds to scale the image first, translate with pixel accuracy and scale down again. Unfortunately, this approach is too computationally expensive for my use case.
MWE with opencv:
QUESTION
So far I gathered:
Windows Internals Book
MSDN C++ service implementation sample
Qt-Solutions QtProject/QtService
Problem is that example service from Qt-solutions is not running event loop. It is using QCoreApplication but somehow exec() does not start event loop (something with the threads ?) It must have something to do with project being somewhat old (last real update was added 3 years ago) and Qt 5.10 being somewhat new. Fix is probably not hard but I would like to understand how the whole thing could be designed. I'd prefer to find problem myself but if someone wants to check it I will accept that answer as well.
This is how I understand windows service program should look like:
There are at least two threads in this setup. First one (T1) is created for executable and entry point is usual main() which is supposed to call StartServiceCtrlDispatcher() that blocks. It passes function pointer to service main function. Let's call it SvcMain().
System will create another thread (T2) with entry point being SvcMain() which should as soon as possible run RegisterServiceCtrlHandler() to register another function as service control handler let's call it SvcCtrlHandler() and then do whatever it is supposed to be doing.
In Microsoft example SvcCtrlHandler() signals via SetSignal() / WaitForSingleObject() which is not really useful method as it will block SvcMain execution but that is not important (I think).
Questions are:
1) Qt event loop should be incorporated into second thread. Can this be done simply by creating QCoreApplication and calling exec from SvcMain() ?
2) How service manager will signal service ? Does it run SvcCtrlHandler() in thread T1 ? If that is correct then why I have to register it from T2 ?
3) If above is correct I need to create Qt event in T1 without running Qt event loop, or use some other, windows based, mechanism ?
4) I can talk back to service manager from T2 to signal it back that i've heard it ?
...ANSWER
Answered 2017-Nov-08 at 06:51How service manager will signal service ?
It (repeatedly) calls SvcCtrlHandler() with an appropriate argument (SERVICE_CONTROL_XXX). It's upon SvcCtrlHandler() to communicate with T2 (SvcMain()).
Does it run SvcCtrlHandler() in thread T1 ? If that is correct then why I have to register it from T2 ?
Let's put it this way: SvcCtrlHandler() runs in the thread, which called StartServiceCtrlDispatcher() (usually T1). But you must register it (with RegisterServiceCtrlHandler()) only after StartServiceCtrlDispatcher() called, so you can't do it in the same thread.
I can talk back to service manager from T2 to signal it back that i've heard it ?
Yes, by using SetServiceStatus() WinAPI, but there are different states to report to SCM. So you are allowed to call SetServiceStatus() from both SvcCtrlHandler() and SvcMain(). For example, SvcCtrlHandler() reports SERVICE_STOP_PENDING, signals to T2, and simply returns, while SvcMain() reports SERVICE_STOPPED and exits.
Problem is that example service from Qt-solutions is not running event loop. It is using QCoreApplication but somehow exec() does not start event loop
I'm not sure which version of Qt-solutions you're looking at, but finding one (really old) in my computer, I see that they actually have it run in T1. However, there's a trick: StartServiceCtrlDispatcher() is called from the dedicated T3 thread, so T1 is not blocked by SCM. Thus we have T1 running QCoreApplication's event loop; T2 running SvcMain(); and T3 used by SCM to invoke SvcCtrlHandler() when needed.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install qt-solutions
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page