I've just downloaded a copy of QT to evaluate if it will work for a project. My first goal was to create a library that contains a dialog. The goal is to see if QT supports the ability to create modules that can be loaded into various programs. Similar to the way you can create a .dll in Windows and place resources inside.
Is this possible (or reasonable) to do in QT?
If so, how? If not, what options are there for creating reusable QT modules?
Yes, it is definitely possible to have Qt dialogs within a shared library but there are caveats. The biggest issue is that you need to have a full QApplication event loop running, which is costly to start and maintain each time you want to call a Qt-based dialog, and also means an increased amount of libraries to distribute.
Related
I would like to interact with an opened qt window (wrote in c++) using code. The code would act like a user and will be completely independent of the code of the qt window. Something like web scraping but with qt (which is much more complicated).The first thing I’m attempting to do is to mimic a click on a push button.
My first intuition was to add some c++ code to the existing code at runtime and execute something like « pushButton.click(); ». After some few searches I tried to use dynamic shared library. The library would implement the code of the button I want to click on, and would be dynamically added to the existing c++ code. This solution could work but seems to be very complicate and not portable. Furthermore I would like the solution to be very independent of the window code.
Of course the qt code of the window will be accessible from the scraping code side.
Are some other solutions more practical ?
EDIT:
GammaRay seems to work fine. I manage to perform a click on a pushButton using the GUI. However, GammaRay doesn't seem to provide a command line interface form. As we can read in the official documentation:
The GammaRay client is available in two forms:
as a standalone application as depicted in the following screenshot
as Qt Creator plugin (for Qt Automotive Suite only)
Is there any possibility to perform a click using GammaRay and without GUI? Are some other solutions work using code only?
The purpose of GammaRay is introspection and not automation. I recommend to use Squish (https://www.froglogic.com/de/squish/editions/qt-gui-test-automation/), depending on the required licenses the price is not so high.
If you don't want to spent the money, then you have to create your own IPC Interface with Remote Commands.
Here is my situation:
I'm developing a C++ application in Creator/Designer with Qt 5.6 on Windows 7 64-bit
I'm designing a skeleton GUI that doesn't do much on its own. It mainly provides a mechanism to integrate engineering tools built by other developers (Plug-ins if you will, not to be confused Plug-ins to Qt itself). The skeleton will be installed on workstations around the office, and it should be able to pull these Plug-ins from a network location and install them to the skeleton without recompiling. On startup, the skeleton should read its list of Plug-ins and build its menus, toolbars, and UI Widgets accordingly.
So the question is ultimately this: Does Qt provide a way of adding .ui files and associated code to a QMainWindow at run time?
Can it do so in such a way that the skeleton will not have to be changed, recompiled, and re-deployed whenever new Plug-ins are created?
Close, but no cigar: Here is an example of a calculator UI created in Designer being pulled into another program dynamically, but it appears this method uses the .ui file only. In other words, the boxes and buttons are pulled from the .ui file, but its logic is implemented in the "skeleton." I need to do something akin to embedding the calculator as its own fully functional Widget at run time.
Side question: If there isn't a nice mechanism provided by Qt, are there disadvantages to having the other developers compile their Plug-ins as DLLs for my particular case?
There's some basic misunderstanding of what a Qt application does. Every single widget you're seeing is instantiated by executing C++ code - it is all done dynamically, at runtime. The uic takes a foo.ui file and turns it into ui_foo.h. That defines a class that can populate a base widget with children.
You can use the QUiLoader to parse a .ui file and instantiate its objects at runtime, but there's little point to doing that since the other code is still C++, so it's simplest to have a plugin project that converts .ui files into C++, then compiles those along your other code and links them into a plugin dll.
The plugins are simply .dlls, ideally providing functionality consumable by the Qt plugin system, that have all the code needed: the code the comes from .ui files via uic, and the code the plugin authors wrote by hand. A plugin is an object factory: it will create QObject instance(s) that can then provide your skeleton with all the widgets and other objects it needs.
That's all. The plugins are .dlls, and you're of course free to download them from a network location to a cache folder, and open them at runtime.
There's no difference between plugins "to Qt itself" and plugins to your application: Qt is C++ code, just as your application is. While it can consume the functionality of some plugins, the rest of them are for your code to consume.
For inspiration, you should look at the sources of Qt Creator itself. It is a completely plugin-based application, the core is a plugin container that doesn't do much. Probably you could reuse the Qt Creator core as the basis for your application, with either no changes or very minimal changes. It would come with a network discovery plugin that gets the remaining plugins from the server and into the cache, and then loads them up. Such a plugin can be probably written in 150 lines of code, excluding the minimal boilerplate :)
I was wondering either it is possible to run an external application inside a QT widget under windows operating system. For example, if I were to write a Qt gui application, where in one of the dialogs user could write some text, I could use a textbox there or something similar. But instead, would it be possible to run Notepad++ or windows notepad application in that dialog?
I would appreciate all help.
It is not really practical to do what you describe at the application level, embedding an entire process into a window of another. (It would be technically difficult and the user experience would likely be pretty bad if you could pull it off.)
Fortunately, this very problem of application components has already been solved!
So it is possible to get the end result you describe via a slightly different mechanism. Many applications expose COM interfaces for automation and embedding, and it is possible to embed COM objects within a Qt application.
(Older technologies such as DDE, OLE and ActiveX provided various aspects of this but are all basically deprecated in favour of COM AFAIK.)
Hopefully you can find a COM object from a third party, or find an app that exposes its components via COM and assemble your app that way.
Have a look at the Qt documentation:
Active Qt - ActiveX and COM support for Qt
I only write QML app with Qt 5.1.1 running on Mac & Windows.
Anyone know what's the version of Qt for Embedded System integrated in the uclinux?
Do the Qt on uclinux support QML? Do I need to re-implement the UI with Qt widgets in C++ to run it on the uclinux?
First and foremost, please do not ask several subquestions in a question.
Anyone know what's the version of Qt for Embedded System integrated in the uclinux?
There is no such a thing. Qt 5 is meant to be well supported for embedded, too, without external third-party projects.
That being said, you may ask Digia about their embedded plans, like Boot2Qt and so on.
Do the Qt on uclinux support QML?
That is the wrong question around. The correct question is whether Qt/QML suppports uclinux. I do not think this will work off-hand, no. You will probably start writing a custom mkspecs file for your scenario and fix lots of issues.
Do I need to re-implement the UI with Qt widgets in C++ to run it on the uclinux?
That would probably be even worse as they are having a lot of overhead in terms additional layer. What I would suggest is to forget about QML for now, and try to bring up a simple screen with QScreen.
As stated, I do not think even that will work off-hand, but if you are enthusiastic, you could get it work.
Since Qt 5 has a hard dependency on the standard library these days, your first task is to get that building againt your mmu-free uclibc. There was some discussion about that here.
But honestly, you may be better off with some lightweight gui framework that supports framebuffer for rendering. Qt is big and not properly tested on minimal systems.
What I am trying to do is create an exe (not .hta) that can be programmed to open a local html file and have it work just like it was in IE (handle styles, scripts and etc), only without actually loading IE. The exe must also be run without installation requirements, and no dependencies (other than recent IE obviously), needed on the host machine.
The purpose is to create an interactive e-book type document, that can be edited without recompile, and also be run from cd/usb on the fly.
I can't just open IE, because it will look unprofessional with the big E, the toolbar and tabs all at the top. know what I mean?
I have experience with HTA, and this was my first suggestion, however I would like to take advantage of the auto run from cd, and also to make the form border a little different, less plain.
I also have experience in VB. Which I could accomplish the look and functionality, however those vbruntimes are not installed on some machines :(
Is it possible to use the IE webBrowser control from c++ or even assembly?
Thanks in advance!
It appears, Lucian Wischik's Webform can be a good starting point to meet your minimalistic project requirements. Alternatively, you could host WebBrowser ActiveX control directly using ATL AxHost. ATL can be linked statically and adds a very low size overhead to the final EXE. Here is a sample project of WebBrowser host app which only depends on ATL.
Yes, you can use the browser component from C++.
C++ however will again need runtime libraries, similar to VB. The good news is, you can statically link those runtime libraries with the executable.
You will not be able to statically link the browser component with your executable, but that wont be an issue unless you try to support ancient Windows versions (pre NT 4.0). For all more recent Windows versions, you can pretty much assume that this component is available.
For more details on that component, you may refer to the CHtmlView class reference - that is the MFC wrapped version of that WebBrowser activeX component.
Using that component from assembler certainly is possible as well, but unless you are deeeeeeep into system programming on the windows platform, you will fail.