I'm using Qt.
I could not find the function or class to start application at booting time.
In windows, for example, add register to HKMU/Software/Microsoft/Windows/CurrentVersion/Run.
I wanna know the function/class like above example.
You can use QSettings in order to set a value at Windows Registry.
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run",
QSettings::NativeFormat);
and then use the setValue function.
However this will work only in Windows so it is better to use an #ifdef before calling it.
The only thing I can think of is the QtService framework. It is available for all the major platforms (look here). It might not be exactly what you were looking for but it may help.
It is also important to mention that a Windows service has no direct access to the graphical interface. This means that if the application is graphical, you'll probably have to redesign it.
There is no such API in Qt, you have to search for 3rdparty library or write whole code on your own.
Related
I am looking for a way to interact with OptaPlanner directly from the command line interface (CLI) without having to use the graphical user interface (GUI).
More specifically, I am looking to pass an XML file to the Employee Rostering function, and to get the solved XML back. Ultimately, I am looking to interact with OctaPlanner from my PHP application.
Any documentation for this?
Here is some what of an example of what I which to achieve:
http://www.c0940097.ferozo.com/applying-optaplanner-to-everyday-problems/
The UI is only for the examples. Take a look at CloudBalancingHelloWorld.java which solves without a UI.
Or, if you're looking for a more enterprise approach, use OptaPlanner Execution Server (also ASL), which exposes everything as REST api's.
I have two projects that both use the settings:
QSettings settings(
QSettings::SystemScope,
QCoreApplication::organizationName(),
QCoreApplication::applicationName());
I was under the impression that with SystemScome and the same application and organization names that these settings would be linked. But they aren't. What's the best approach for this?
Thanks!
EDIT:
It was on Linux, and I believe sudo needed to be used for SystemScope. UserScope did however work.
As it is thoroughly written in documentation - QSettings: Platform Specific Notes the path which QSettings use to store settings is uniquely determined by application and organization name parameters.
The First thing you could do is to check is settings are truly being written in location mentioned in link above for your system and what is different for those two applications. For example, there is a singular case that for windows their will be different for x86 and x64 applications.
Also if you try to use them simultaneously for both applications you should remember to use sync () function or create new QSettings instances when it's needed so the apps wouldn't conflict in operating on them.
I am writing a Qt application that calls QProcess::startDetached("wscript.exe script.vbs") to show the delete confirmation dialog in Windows.
this is the script:
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("-")
Set objFolderItem = objFolder.ParseName("-")
objFolderItem.InvokeVerb("Delete")
the arguments for Namespace and ParseName are from the arguments passed to the script.
This may be inefficient because it opens an external application first before running the script. I was wondering if i can run VBScripts in a Qt application.
If not, what alternatives can i do?
My VBScript is very weak, so I'm not 100% sure I understand what you are trying to do. My assumption is that you are trying to delete a folder, but want to give the user the normal confirmation box and animation while the action is occurring. If that is not correct, please let me know and I will remove this answer.
A few ideas:
You could call the Windows API directory within your C++ code to do this. I believe the correct call would be to use IFileOperation (Vista and later) or SHFileOperation (pre-Vista)
Qt already has message box dialogs. Although you might not get the exact same functionality as the native shell, you could use this (QMessageBox::warning) and then delete the folder using QDir. This would also be cross-platform portable.
If you stick with the VBScript, I doubt you would see any performance issues unless this is being called many, many times in a loop or something. You know, the old "premature optimization is the root of all evil" thing.
You should read up on the IActiveScript COM interface. You can create an instance of an interpreter that implements IActiveScript to provide a runtime for evaluating scripts. VBScript and JScript can both be used for this and a number of other third-party scripting languages also provide IActiveScript support.
The overview for working with this is you create a language runtime (an instance of VBScript for instance) then add some custom objects to it. Typically if you are embedding an interpreter into your application then exposing an Application object is a good place to start. This can be just an IDispatch interface or something more concrete with an IDL generated typelibrary and all the trimmings. Once you have added the necessary named items into the runtime you load one or more scripts. Any public functions or subroutines declared in the scripts now get exposed via the IDispatch interface of the live runtime once you switch its state to active or running. To actually run the script program, I invoke the Main function for my stuff - you could choose some other scheme as applicable to your environment.
The nice thing about ActiveScripting, is to change language you just change the runtime CLSID. So if people prefer Perl they can use PerlScript or PythonScript etc. Your Application object remains the same hence you don't have to write additional code to support the new languages. The only requirement is that everything is COM.
Thinking of implementing a LDAP-viewer in QML. The first step is obviously to make a Qt back-end that can handle ldap-queries. I've read the rfc1823 (ldap tutorial of sorts), but still can't understand where to begin really.
I would be interested in some Qt code that would get me started on some sample LDAP functions, for instance :
connect to a ldap server
do some simple query of any type
close the connection
Edit: code is not required if you can point me to any tutorials/guides as to how one does this in C++ / Qt
I suggest using libldap. Writing a client from scratch is a lot of work. Take a look here for some examples as a kick-off. You can easily integrate that code with Qt.
The OpenLDAP library also has some c++ example included.
I need to make so that my application can have only one instance running at a time. Also when it's launched with a command line parameter ( like when registered to open certain file types ) it should pass the parameter to an existing instance and quit immediately without displaying graphical interface. You all probably know what I mean. The framework used is Qt 4, and it seems like it must have some facilities for that. Any ideas?
There is a Qt Solutions project doing this:
Qt Single Application
There are several ways to do inter process communication. Examples can be found in Qt's examples section.
It's also possible to implement a this sort of class oneself using QSharedMemory
(see QSharedMemory::attach() ). It's capable of being used for both determining whether other instance is already running and communicating/sending messages. Except some pointer magic and memory copying it's quite straightforward.