QT: Launch default exporer on a directory selecting a file - c++

My application displays a grid of images. When the right mouse button is clicked a context menu is displayed where the first option is "Show in Explorer".
I was able to launch the default explorer on the directory by using:
QDesktopServices::openUrl(QUrl::fromLocalFile( directory ));
However I want also the file to be selected.
Is this possible? I suppose it should be, as many apps can do that.

openUrl is not suitable here. You need just start another process (with QProcess start or startDetached) with Windows explorer special arguments:
explorer.exe /select,"C:\pathTo\file.txt"

Ok, I want to thank #Chernobyl for his useful help.
However I've found a general solution posted here:
How to "Reveal in Finder" or "Show in Explorer" with Qt
It wasn't compiling at first because the QtCreator code is using a class called Environment which I tried to add to my project but that file then also includes others, etc. I checked and they are using it just to see if explorer.exe can be found on the system path. It was not so important (to me) so I removed that check and then I tested it. It's working perfectly. It's also supposed to work for Mac and Linux.

Related

How to fix "This file is not part of any project. The code model might have issues parsing this file properly." bug in Qt Creator?

I just installed Qt creator (for the 10th time probably), and even when I follow the simple steps to create a new Qt Widget or Qt Console applications, I get this error. Extremely frustrated with various Qt Creator bugs. Help will be appreciate.
If you look closely at your workspace, you can see, that there are two projects. One project is called Sample, one project is called Widget. The active project is "Sample". You can tell that from the project browser as the Sample project is in bold letters. So building and debugging applies only to the Sample project.
The open file where you set your breakpoints in is "Widget/main.cpp", it belongs to the other non-active "Widget" project. So when you start the debugger, the environment warns you that this will not work. Completely correct behaviour.
Maybe try the following:
1- Ensure case sensitive typing of the file name and type the full path not just the name.
2- Delete configuration files that are automatically created.
3- Make sure the QT environment is setup correctly pointing to the required compilers, packages and resources.
4- Check if there are any missing environment variables on your machine.
The problem could be in the .pro
Check that you have the file into the source in the .pro

How do I turn my C++ code into a .app file? [duplicate]

I am building a C++ OpenGL card game in Xcode 4.3.3, with the intention of running it on both 64-bit and 32-bit Macs, which is not my problem. My problem is that I have reached a point in the development of the program where I would like to test that it works on a different 32-bit Mac (mine is 64-bit) without having to install Xcode. This, obviously, requires me exporting it as an .app. I can find and run the exported Unix Executable File from my project, after some cd'ing, through Terminal, but that is undesirable for me and the intended audience of the program. I have trawled the google and Stack Overflow, looking for anything to help me, but all the things mentioning Archiving seem to have been unsuccessful with my particular project, and I think that's because it's a C++ command line tool project. So, can someone please help me export my project as a .app?
Thanks in advance.
The simplest way of doing this would be to create a Cocoa project, go to 'build phases' and remove all the objective-c frameworks from the 'link with libraries' build phase, remove any objective-c files added by the template (app delegate, etc.) and then replace main.c with your main.cpp file.
There's nothing really special about a Cocoa project except for the fact that it links against Cocoa and calls NSApplicationMain() from its main() function.
There are also a bunch of .plist entries used by Cocoa which you'll no longer need. But they won't affect the way OS X treats your application.
I'm searching for an XCode Settings solution but here's my current way to create an app:
You have to take your binary file (let say myapp) and put it in "MyApp.app/Contents/MacOS/myapp" then it can now be launched as a .app. That's a trick.
Just go to the targets folder in the file navigator on the left, and there will be an executable listed there. Left click on that executable and click "show in finder". (I'm describing from memory so I may have the exact details wrong.) The file path is ridiculously long (there is an arbitrary alphanumerical pathname involved, I have no idea why), so you probably won't be able to find it with the command line.
If you want you can change the extension of the file from nothing to ".app", it shouldn't affect the nature of the file at all. Also if you want a custom icon, you can "get info" on it in the finder, then click on the icon in the info window, and use Cmd-V to paste it in (obviously you have to have your icon copied to the clipboard). There is also a way to do this inside of Xcode, but I don't remember it.

Sitecore 7.2 Command Configuration

I'm trying to get a command working in a new instance of Sitecore 7.2. The command that I've added lives in a different assembly than the main project for this web application. I've added the full path to the file for the command, along with the name of the compiled assembly in the App_Config/Commands.config file.
In Sitecore, I've added the command template under the branches/user defined folder and entered the command name from Commands.config, in the Command field. I've then added the command as an insert option on the appropriate item in Sitecore.
When I log on as an admin and click the command link under the Home tab in the top menu, nothing happens. No error is generated and the pop-up window does not appear - just nothing.
Having configured commands many times before in earlier versions of Sitecore, I can't think of what I'm missing... The only difference this time is that the file for the command is located in a different assembly. Am I missing a step somewhere that is needed, in order for this to work? Did something change in Sitecore 7.2?
It looks like there was an error in the reference to the namespace. Once I updated that, the code ran. The frustrating thing was that Sitecore wasn't generating an error. It just wasn't responding, at all.
I had a similar situation the other day. I had a Visual Studio solution with just one Class Library project and one C# class in the project. I wrote some code in that class, built the solution and moved the DLL into my Sitecore website's bin folder. I tried running the feature in Sitecore and nothing happened. I confirmed I was referencing the DLL appropriately. I then used the debugger in my Visual Studio to attach to my process and sure enough, the method parameters that Sitecore was supposed to set in my method signature were not getting set.
After trying a lot of different things, I decided to add a Web Application to my solution. I then moved the code from the Class Library to the Web Application and updated Sitecore to reference the Web Application DLL instead of the Class Library DLL. All of the sudden, my method parameters were set and the rest of my code worked as expected!
So my suggestion is: if you have the code the in a Class Library right now, move it to a Web Application project and see if that helps.

Can't change system variable "Path" for netbeans

I downloaded Netbeans because I wanted to start learning C++. I downloaded the compiler, debugger, and make utility from cygwin. In order to complete the process of setting up my IDE I need to modify the system variable Path to reflect my new cygwin installation.
So here is what I do:
type var into windows search
click on Path in the system variables
Here is where the issue arises. The instructions I am reading tell me to edit the Path variable, but the buttons are unclickable. They remain faded even after clicking Path. When I double click the Path variable I hear the windows "error" chime.
I don't know why I can't modify the Path system variable. I have ensured that my account (the only one on the computer) is an administrator. I am running windows 7 if that makes a difference.
Thanks,
Alex
I solved it just now. Even though the end destination is the same, typing var into the search bar opens the environment variable window, but prevents editing. However, if you right click Computer, select properties, select advanced settings, then click on environment variables, even though you're in the same location, the variables are then editable.

convert a console app to a windows app

(its a long story) but I have a large complex project file containing a windows program. Unfortunately the project was originally built as a console app. The program compiles and links ok but when runs brings up a console instead of the collection of windows I was hoping for. I looked at the command line and saw "/SUBSYSTEM:CONSOLE" whereas it should be "/SUBSYSTEM:WINDOWS". I have no idea how to change the command line. Is there some box I can tick in the project setting somewhere to make this change?
Right-click the project icon in the Solution Explorer, then Properties > Linker > System > SubSystem, and set that to Windows. You'll also have to change your main() method to WinMain(). And you'd better create some windows or there won't be much to look at.
Complementing Hans' answer: While under Properties, also remember to expand the C/C++ node and select Preprocessor. Then edit the Preprocessor Definitions - replace _CONSOLE with _WINDOWS.