I am currently messing around with plugins in Qt5 (QPlugin). More specifically I have been looking into this example:
https://doc.qt.io/qt-5/qtwidgets-tools-echoplugin-example.html
There they create an abstract interface class to access functions in the plugin. Now here comes the question: Does this work the other way around?
Say I do stuff in my plugin and want to print some results to a GUI which lives in the main application. Can I call GUI functions from within the plugin? Or is there another way to achieve this kind of communication from plugin to application?
Messed a bit around and...
Answer was, to simply send the Main GUI's pointer as parameter of one of the interface functions and storing that pointer in the plugin class. That way, you can access the GUI (and other classes in the main application) from within the plugin.
Related
I'm currently looking into Qt RO as a possible solution for my current need to remotely access a UI without using Qt WebGL. I am having trouble finding any good example uses of Qt RO outside of the starter ones in the qt docs.
Will Qt RO fit my needs and does anyone know of a good example?
Custom types work just fine with Qt Remote Objects. Just like with any other meta object compiler issue in Nuke, you just need to make sure that the type is known to the meta object compiler.
So, for example, you will need to register it.
PROP(SomeOtherType myCustomType) // Custom types work. Needs
#include for the
// appropriate header for your type, make
// sure your type is known to the metabject
// system, and make sure it supports Queued
// Connections (see Q_DECLARE_METATYPE and
// qRegisterMetaType)
https://doc.qt.io/qt-6/qtremoteobjects-repc.html#prop
You can also find more information about how to handle custom types in Qt in general here. You would register your type like this:
Q_DECLARE_METATYPE(Message);
https://doc.qt.io/qt-6/custom-types.html
I am trying to learn hooking and want to hook only an .exe's send/recv function.
I'm building the project as a .dll and then injecting it to the .exe
Edit: solved
There are 3 ways of hooking an API call as far as I know:
Inject a DLL in the application that will rewrite the Import Address Table containing the address of the API call, so that the application calls your function instead;
Write a dummy DLL with same name of the DLL with the API call you want to hook and place it in the applications's root directory, so it will load your APIs instead of the system's;
Detour the API call by rewriting it's code with a JMP yourfunc or something with similar effect.
Method 1 is pretty popular one, it's even described in the Wikipedia page about Hooking and in various examples if you Google it, like this one, or this one.
Method 2 is a bit tricky, you have to build a DLL with the same name and exports as the one you're mimicking, and bypass all the functions you're not interested in hooking and write custom code for the one you are. I find this method very clean because you don't have to modify memory, you don't have to explicitly inject this DLL using an external program, Windows just does it for you, and with a plus, it generally fly under the radar of anti-debug and anti-hack detection. Here is an example of how to do that (32-bit).
Method 3 is Microsoft's favorite. It has a particularly good advantage: You can hook any and every function, method, or virtual calls. It doesn't depend on the function being called externally to hook it, so it's very popular to hook DirectX methods for instance. This is the method used by FRAPS, Discord Overlay, Overwolf Overlay and pretty much every other software that either places an overlay in games or records gameplay. You don't need to use Microsoft Detours specifically, there's the generic alternative aswell.
The problem
I would like to use c++ to create an application that uses the new macbook pro touch bar. However I am not able to find any really good resources. And apple does not have any docs on using c++ to program the touch bar.
What I have done
I found this article on c++ and the touch bar, However I cannot find either of the header files for the script GLFW/glfw3.h and GLFW/glfw3native.h. These both seem critical to the script working.
More on the issue
Even if the above article's script works, there are no official docs for programing the touch bar with c++ (That I know of). I think that this is an important thing to have given the fact that many, if not most applications are written in c/c++.
Thank you in advance for the help!
So the article that you link to basically does not need the GLFW/glfw3.h and GLFW/glfw3native.h files if you are not using GLFW.
What UI framework are you using for your C++ app?
Unless it is still using Carbon, at the lowest level, the framework will be creating NSWindows to actually have windows in the UI. You need to get access to the NSWindow that your framework is using to host it the UI. If it is still using Carbon, I think you are probably not going to be able to accomplish this.
If the framework provides some mechanism to get the native platform window (which will be an NSWindow), you would replace the author's call to glfwGetCocoaWindow(window); with the correct call from your framework.
If the framework does not provide access to the NSWindow, then you will need to use the code that is commented out at the bottom of the article to attach your touchbar to the windows in your app.
Please note that all that code is Obj-C code; you'll need to have at least one .m or .mm file in your project to provide that Obj-C glue code to get access to the touchbar. Basically that code is a C-calleable wrapper around the Cocoa API.
Also note that you'll need to expand the list of buttons and actions for all the different things you want to put in the touchbar. You could add your own wrapping API so that the construction of the toolbar is done from C++ and registers actions that call-back into your C++ app to handle the events.
Fundamentally though, the touchbar is not available on any other platform, so there is no great benefit to trying to avoid writing Obj-C to implement your touchbar as that code will only run on macOS anyway. If you use .mm files to implement Obj-C++ for this code, you can still call into your C++ objects from your touchbar code.
In .NET WebBrowser Control, there is a Property named "ObjectForScripting". As you call window.external in Javascripts, it calls then the Function in .Net Code.
I'm wondering if this exists also in C++ wxWebView? Or maybe in another C++ GUI Library WebControl..
There is nothing like this in wxWebView at the moment, just the simple RunScript method. However there has been some work on doing this using the Webkit based wxWebView backends, more information is available here.
This is a followon to a prior question I posted (see here). I'm trying to call my native/C++ code from Javascript running in an HTML page. The answer in the referenced question was to create a COM object. The Javascript can then create an instance of the COM object and invoke methods on it getting to the native/C++ code.
So now I'm left with trying to create a simple COM object to accept the call from the Javascript. It looks like the way to go is to create a DLL and put the COM object in that DLL. Years ago I did tons of reading on COM and have tried to forget it since then :) Now I'm getting a headache wondering how to go about this easily without becoming an expert in COM.
Is there a simple/easy way to setup a DLL with a COM object that you would recommend?
EDIT: My application is written using native C++/Win32/MFC. I have an MFC dialog which uses the IE ActiveX browser control to render locally generated HTML. Currently the button handler code is all in Javascript, but as you can see from the referenced question, my goal is to handle it on the C++ side.
As I know the easy and fast way to create COM objects is to create an ATL project.
here's a nice tutorial that explains the steps to follow.