Using Qt to open external game application - windows

I have a windows qt application and I'm trying to open an external game, but I'm not having success.
Application is in C:\games\Oni\Edition\ and is called Oni.exe, the code I'm using right now is the follow:
void MainWindow::on_toolButton_clicked()
{
qint64 test=1;
if(!QProcess::startDetached("Oni.exe",QStringList(),"C:\\games\\Oni\\Edition\\",&test)){
QMessageBox msgBox;
msgBox.setText("Oni couln't be started!");
msgBox.exec();
}
}
I don't know if I'm forgetting something? The game runs fine if I double click it. Thanks.

Alright, figured it out.
Just replaced the code:
QProcess::startDetached("Oni.exe",QStringList(),"C:\\games\\Oni\\Edition\\",&test)
by
QProcess::startDetached("C:\\games\\Oni\\Edition\\Oni.exe",QStringList(),"C:\\games\\Oni\\Edition\\",&test)
And it's working like a charm.
I had also tried QProcess::startDetached("C:\\games\\Oni\\Edition\\Oni.exe"); before but didn't worked, seems we need to put always the full directory of the executable and also the full directory as working directory. This because seems only executing the file directly, the file itself may be looking for another folders/files in the QT Debug folder, when they are in the game folder. This cause the game quits prematurely. :)
Another solution would be use windows native api like user827992 pointed out in the follow link: QProcess::startDetached blocked by UAC (running an updater)
This latter solution also should work fine with UAC problems.

Related

Unity hub not logging in

I downloaded Unity Hub 2021, and when I press login, it takes me to this website: https://api.unity.com/v1/oauth2/authorize?client_id=unity_hub&response_type=code&code_challenge=Gv3OZwD0-z9TI1h3vy14zdJFU79Gm_RW3RGAmQzcd5E&code_challenge_method=s256&redirect_uri=unityhub%3A%2F%2Flogin&locale=en_US and when it opens, it just displays a black screen and nothing happens; I don't login. Please I need this to be fixed. I have a project I'm working on.
Solved - I went into Registory Editor and deleted the Unity Hub file. And it magically worked.
If you have ever changed the Unity Hub path, you'll need to change the path under this key in registry again.
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\unityhub
Like this.
For me removing registry key didn't help. I was able to solve issue by basically running "Unity Hub.exe" with arguments contains full URL, e.g.: use this command line from the place unity hub executable is located:
"Unity Hub.exe" unityhub://login/?code=SOMECODE&locale=en&session_state=SOMESESSION
This URL you can find by looking on the source of html page on which you got in stuck. For sure, this is temp solution just to be unblocked.

Cocos desktop app can not access to files on MacOS

I have an application with the following structure:
./Data/test.txt
./TestMacOSApp
So my TestMacOSApp opens ./Data/test.txt and uses the content of test.txt. This app was working for a long time either on my MacBook or others MacBook. Recently I noticed that the app works on my MacBook fine,
but on others it crashes throwing "File is not found exception".
I create TestMacOSApp using XCode v9.1.
MacOS version is 10.12.6.
The App creation steps are Archive->Export->ExportApp (Without re-signing).
Does someone else have such an issue?
How can I solve this issue?
I don't know how you open the file because you didn't provide the code which does this.
But I know that, when you export your app on other computers, it is important to calculate the real path with fullPathForFilename, instead of giving directly the path that you know. Like this:
auto fileUtils = FileUtils::getInstance();
string content = fileUtils->getStringFromFile(fileUtils->fullPathForFilename(filename));
Have you done this? If you have, and it doesn't work, your file is probably just not where you expect it to be, so please check again.

Deployed Qt5 Application Doesn't Print or Show Print Dialog

I'm experiencing Qt4 to Qt5 troubles. In my application when the user clicks the print button two things should happen, one is that a PDF gets written to disk (which still works fine in the new version, so I know that some of the printing functions are working properly) and the other is that a QPrintDialog should exec() and then send to a connected printer.
I see the dialog when I launch from my development machine. The application launches on the deployed machine, but the QPrintDialog never shows and the document never prints.
I am including print support.
QT += core gui network webkitwidgets widgets printsupport
I have been using Process Explorer to see what DLLs the application uses on my development machine, and I believe that everything is present. My application bundle includes:
{myAppPath}\MyApp[MyApp.exe, Qt5PrintSupport.dll, ...]
{myAppPath}\plugins\printsupport\windowsprintersupport.dll
{myAppPath}\plugins\imageformats[ qgif.dll, qico.dll,qjpeg.dll, qmng.dll, qtga.dll, qtiff.dll, qwbmp.dll ]
The following is the relevant code snippet:
void PrintableForm::printFile()
{
//Writes the PDF to disk in every environment
pdfCopy();
//Paper Copy only works on my dev machine
QPrinter paperPrinter;
QPrintDialog printDialog(&paperPrinter,this);
if( printDialog.exec() == QDialog::Accepted ) {
view->print(&paperPrinter);
}
this->accept();
}
My first thought is that the relevant DLLs are not being found come print time, and that means that my application file system is incorrect, but I have not found anything that shows me a different file structure. Am I on the right track or is there something else wrong with this setup?
This was another classic Windows/Qt5 deployment problem with a combination of missing plugins and plugins placed in incorrect places. By using the environmental variable QT_DEBUG_PLUGIN and adding CONFIG += CONSOLE to my PRO file I was able to see that on my development machine the application was loading qminimal.dll which I was not shipping.
The application root which I have defined as {myAppPath}\ is the root directory for plugins. Therefore the correct file structure is:
{myAppPath}\MyApp[MyApp.exe, Qt5PrintSupport.dll, ...]
{myAppPath}\platforms[qwindows.dll,qminimal.dll]
{myAppPath}\printsupport*
{myAppPath}\imageformats*
{myAppPath}\bearer*
Thanks peppe for the lead.

Running AntlrWorks2 stand-alone on Windows 7

I must be missing something. After downloading AntlrWorks2 I found the executable bin/antlrworks2.exe and bin/antlrworks264.exe. Aren't these supposed to be the standalone version of the tool? Neither works for me; after a NetBeans splash screen, the first times around I got an error message on missing packages; after a couple of times I chose to go on regardless, but now (still after the initial spash screen) there is simply nothing happening at all.
I can't find any tutorial or manual detailing how to run AntlrWorks stand-alone, so any help is much appreciated.
This is due to a bug in the NetBeans platform. I filed a report but it hasn't received a reply yet:
Cannot launch platform application after moving installation folder
Here is a workaround that does not delete any preferences you have customized:
I found that deleting just the var folder under the user's generated
.antlrworks2 settings folder resolves the issue...
Still an issue as of date of this post. Deleting the .antlrworks2 folder from \users\username\AppData\Roaming does work - you can find this folder by putting %APPDATA% into your file explorer address bar (exactly as shown) - that will go to the app data folder for your current user login session. Delete the .antlrworks2 folder and then re-run the app.

Another knack on the "Dialogs must be user-initiated" Security Exception in Silverlight printing

I get the infamous "Dialogs must be user-initiated" Security Exception when I try to print some stuff in Silverlight. As you can see, the dialog is as user-initiated as can be:
John Papa couldn't help me much out neither, because I don't have any breakpoint set. Mr MSDN thinks it could also be that I'm just taking too long, but this is a demo application just as simple as can be.
Any ideas? I guess it's a Visual Studio quirk, maybe some extensions interfering, as things seems to work when I launch the application outside of it. I first thought maybe the Code Contracts are interfering with their IL weaving, but they are deactivated for this project.
Update: This is just a simple Silverlight application that runs locally from the file system. When I do "Start debugging", Visual Studio creates a hosting HTML file containing the Silverlight app in the Debug resp. Release folder of the project, launches the Internet Explorer with that HTML file and attaches the debugger to it.
Update 2: I also get the same error when I create a web project to host the Silverlight app and create a virtual directory for it on IIS.
I might also want to add that I don't have problems with printing in other Silverlight projects regardless of their hosting scenarios.
Update 3: I downloaded FireFox and it works, I don't get the error when I debug with it. So it seems to have to do with my IE8. I uploaded the solution:
http://dl.dropbox.com/u/10401470/Code/Demos/PrintingDemo.zip
I wonder if anyone can reproduce?
Anyone got an idea to which team I should file a bug report? Silverlight team? IE team? VS Debugger team?
I'm able to reproduce this. You have handled the Click twice, once in XAML another time in code. See your MainPage.xaml
<Button x:Name="PrintButton"
Content="Gotta print 'em!" Margin="8"
Click="PrintButton_Click" />
Don't feel bad about it. I did it last time through a misplaced Print inside a loop.
I've also experienced this strange behaviour. A standard button click event immediately invoking an OpenFileDialog. It would frequently generate the same error when being debugged but would eventually be coaxed in to working when the button is clicked several times.
However when built as a release (or perhaps simply by running the same Xap without a debugger attached to the browser) the problem would go away.
Try to remove
if(SightPaleceListBox.Items.Count > 0)
I had the same problem and found out that the reason was this following line:
cnvsMain.Children.Remove(PrintPagePlaceHolder);
cnvMain is on the page that the user pushed the Print button on (I was trying to remove it from that page in order to add it to the canvas that I was going to print).
My tip: try to comment rows one by one, until you find what row causes the problem. Than try to work around it.

Resources