QT QFileDialog how to hide hidden/backup folders (".folder") - hidden

Basically when browsing folders inside a QFileDialog I find very annoying to have everything bloated with hidden or backup folders (don't know how to call them really); specially on home.
Is there a way to prevent these type of folders from showing by default on a QFileDialog?
I'm using Qt4.6 and getOpenFileName.
P.D.: I'm starting to think this might be an ubuntu thing...?

I use Linux only sporadically, but I believe the "." is just a convention which file managers use to hide files. Probably you'll have to write code to explicitly filter out folder names.
Check out qfiledialog - Filtering Folders?

Related

Qt Open file with context menu entry/shell extensions [Windows]

I'm looking to have a way of opening files in my Qt app within a context menu, like opening any image file in Photos or Photoshop. Mostly what I'm finding though is either possibly out of date ways of doing it, like way earlier versions of Qt, or incomplete posts about doing something with shell extensions, but it's mostly adding an icon to custom file extensions in explorer, not the opening actions. Or ways of doing it with the general Windows API I think, which I don't know how this would "connect" with my Qt app to open a file in it, and the windows api is very scary to me.
Is the way of doing now with a newly added module in Qt using C++, or maybe something with an "installscript.qs" file, or "package.xml"? I've never seen or used a .qs file before. Basically, I'm not sure where to look for how to do it the most updated and easiest way.
The screenshot below is an example of the functionality im talking about. With my Qt app not being open, a file of the types I want (.jpg, .png, .gif, etc) is right clicked, and I can click like "Edit with MyQtAppName", or open the "Open with" sub menu and click "MyQtAppName". Then ultimately this files full path would be passed into my Qt app as a string somehow. I don't know how this pass of the path string happens yet, but yeah. Any help appreciated.

Where can I put my SQLite database in my QT application if I can't put it in my resources?

Recently I was trying to put a SQLite database into a QT 5 application I'm writing. I want it to be universally accessible - that is on all systems regardless of where it's installed. I put it as a resource then found out that evidently you can't put databases in resources as the string for the database path passed to setDatabaseName doesn't get translated to the resource system so the database can't be found.
So where can I put it? I don't want to just put it at the root of the drive like C:\repo.db or D:\repo.db as many people hate files cluttering their root directories (like me). I was going to put it just in the source folder and access it as "repo.db" or as I tried "./resources/database/repo.db" but even QFile doesn't see that. Where can I put it and how to access it there? My settings file was going to be in my resources but I wasn't sure if I could update the file then. I need a place that is available from the moment the application is installed on any system including my own so that it can be accessed both while coding it and when it's built.
I'm not asking for opinions - I want a place that is not in the root, somewhere universal like the installation directory (but how do I find that with code?) or a settings directory (but how do I set that somewhere so I can find it later??)
For such purposes Qt provides a list of QStandardPaths functions that return platform specific standard paths, such as a path to desktop, temp directory etc.
For your particular case you might put your database in the directory that corresponds to the QStandardPaths::AppDataLocation key.
You can use QSettings to save path,settings and restore them.
QSettings m_Arhive("Company", "app_name");
//Set DB path
m_Arhive.setValue("DBPath", "c:/somewhere/database");
//Get DB path
m_Arhive.value("DBPath").toString()

Play background music outside of app bundle using SimpleAudioEngine

I need to play background music residing in the app's document folder (using hosted content downloads which I put in the document folder after download).
It seems that SimpleAudioEngine's way of playing background music is to take a relative path and find it inside the app bundle (CDAudioManager does it):
#"mysong.mp3"
becomes
#"...19E17B5B/myapp.app/mysong.mp3"
Which is not helpful because the file saved into the Documents folder looks like this
#"...19E17B5B/Documents/mysong.mp3"
Edit: It works by specifying something like this #"../Documents/mysong.mp3"
However as we know this would not be recommended/future proof... Any better way to do this?
It works by specifying a relative path like this #"../Documents/mysong.mp3", totally ignoring all recommended ways to get paths :-P

Renaming a form in Visual C++

I start Microsoft Visual Studio 2010. I chose to start a new project on the Welcome Page. Ofcourse my preferred language is Visual C++ and I'm chosing to begin a Windows Forms Application. I give up a name like Calculator for this one. I do not touch the other options on this dialog. The project gets created and a new Form1.h is automatically added to the project, and a Form1.resX is also added. Because 'Form1' is useless to me, I'dd like to rename it to something more VB6 style, like "frmMain.h". So I right click the Form and simply chose "Rename". After accepting my new name, the necessary changes seem to be occuring. first impression But now, when I try to build this project, It gives a BUILD FAILED. When I look into my files.. Form1 is still mentioned..
So my question is: How do you actually/OFFICIALLY rename Forms?
I've been reading a lot about this and mostly the answer is to delete the form, and re add a new with the right name.. I've heard also that VS asks to rename all references to it, but that doesn't show up to me. Some other people say, you have to use the quick replace function, and rename all references to this class and its file.. This is not a good way to me.. Or is it really the standard procedure?
I have programming experience in C++ and I know about classes and polymorfism and so on. But this is one of the simplest things that keeps me annoying!
You are using VC++.NET to create .NET applications (Windows Form in your case). I must warn you that VS is not very friendly for VC (refactoring, renaming, and little intellisense).
In this case, you renamed the form which will make VS also rename the Form1.resX, but it will not rename the class. It will do it if in C# or VB.NET. Just open the .h file and rename the class itself to match the name of the file.
You also need to update the main .cpp file where "main" resides, and update the Application::Run(gcnew Form1()); in there as well include the "#include".
A solution replace will work (Ctrl+Shift+H), but be careful with this.
click on the form -> properties -> text (usually named as Form1) -> change it.

mfc directory picker?

I did see this to modify CFileDialog (http://support.microsoft.com/kb/105497) but it looks like a lot more than I need.
I'm using the CFileDialog to pick files, is there a simple way to use it to just select a directory?
Any other suggestions?
(I also saw this but is for XP only?
http://msdn.microsoft.com/en-us/library/aa163948%28office.10%29.aspx)
(VS 6.0 C++)
You will probably want to use the SHBrowseForFolder API. There are lots of wrapper classes out there that make it easier to use. Like this one.
Dundas Ultimate Toolbox has a folder selection drop-down tree. It is nice because you don't need to open a new window just for selecting a folder.
The class is defined in FolderTree.h and is called CFolderTree.