How to have QFileSelector select files based on device - qt

Reading the QFileSelector Class documentation, I see:
QFileSelector is a convenience for selecting file variants based on platform or device characteristics
I am successfully using the related QQmlFileSelector class to select a set of files based on if I am building for Mac (a +mac directory).
However, I need to also build for Ubuntu Desktop and an embedded device which is also running Ubuntu. Therefore, I cannot just add another platform directory directly related to ubuntu.
Based on the reference to device characteristics in the documentation, I figure I can create a folder directly related to the device.
I have a Kit setup for the embedded device and a Device used by the kit named Ansible.
Can anyone provide further details on how I can have QQmlFileSelector select the files in a + folder when building for Ansible?

You can add your own selectors using any name you want. Here's an example:
QQmlFileSelector *selector = QQmlFileSelector::get(engine);
QStringList options;
if (usingAnsible())
{
options << "ansible";
}
else
{
options << "x86";
}
selector->setExtraSelectors(options);
Then your files would be in either the +ansible or +x86 directory.

Related

Qt5 is it possible to define more than one build configuration?

I am working on application for Mac OS written in C++ using Qt5.7.1, which is distributed both as direct download from website and through App Store.
Now I have a new requirement to add self-update to the application. Which would require building two different versions of application - one for App Store (without self-update mechanism) and one for direct download (with self-update).
I have no problem to implement the self-update, but I am stuck with making a separate build configuration. So the question is -- in Qt5 is it possible to define two separate Release configurations (in a single .pro file) and if yes, then how? It also needs to work with qmake since the builds are automatic (with Jenkins).
You cannot really define 2 Release configurations in a .pro file.
However you can define different configuration options in your .pro file like this:
foo {
#something
DEFINES += FOO
} else {
#something else
DEFINES += NOT_FOO
}
bar {
#another thing
DEFINES += BAR=42
}
And then when you run qmake, add either CONFIG+=foo or CONFIG+=bar or both.
Finally in QtCreator you can define as many build profile as you want and customize the call to qmake for each profile by adding or not CONFIG+=foo options.
For more information check qmake's CONFIG documentation, especially the last example.

Setting custom local storage Path in QML

I m trying to put a custom path in QML file but can't get it done.
I'm trying to get de db in a shared folder where i'm willing to put the DB so any person who has the program can acces to data.
I'm using Sqlite and Qt Creator 5.7 but not a lot of info about this.
You can simply COPY the database from its default path. Typically that is located (In windows anyways) at
C:\Users\<username>AppData\Local\<program name>\QML\OfflineStorage\Databases
and on Mobile devices it is stored in a similar place --
on android its in a sub folder of:
/data/data/<Program Name>
On *nix it is located:
/home/<user>/.local/share/[ProjectName]/QML/OfflineStorage/Databases

How to access public download folder in every platform in Xamarin.Forms

I need to create a backup service so I intend to save the SQLite database file on each platform. The saved file should be available after the uninstall of the app.
I intend to use the Downloads folder (which should be available on every platform).
I have created an interface and use the following code per platform:
Interface:
public interface IBackupService
{
string GetDownloadPath();
}
Android:
public string GetDownloadPath()
{
return Android.OS.Environment.DirectoryDownloads;
}
UWP:
public string GetDownloadPath()
{
return Windows.Storage.KnownFolders.???????;
}
What should I do about that? Is there a public library that I could use?
There does not seem to be a general downloads folder as per this documentation on KnownFolders. So your assumption on the Downloads folder being on every platform doesn't seem to be correct.
If we dive in a bit further we get to the DocumentsLibrary which seems the obvious choice for this kind of purpose, but it is not. Microsoft says:
The Documents library is not intended for general use. For more info,
see App capability declarations. Also, see the following blog post.
Dealing with Documents: How (not) to use the documentsLibrary capability in Windows Store apps
The paragraph after that seems to describe what we have to do then;
If your app has to create and update files that only your app uses,
consider using the app's local folder. Get the app's local folder from
the Windows.Storage.ApplicationData.Current.LocalFolder property.
So, as I can extract from your question you only want to use storage for your app, so the Windows.Storage.ApplicationData.Current.LocalFolder seems to be the right choice according to Microsoft.

Qt Use Same Settings Between Two Apps

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.

How to specify the location for FileReference.browse() in Flex

I have a requirement to select a file from fileReference.browse(), but I want to browse a file to specific location say D:\Dir\file instead of the OS specific (The dialog box is native to the user's operating system).
Is it possible?
Thanks in Advance-
Since you're using File, I'm assuming you're using the Air runtime. To do this, you just need to set the path in the file constructor before you browser; like this:
var file:File = new File(somePath);
file.browse();
The only problem with this is that if you set it as an absolute path (like say, "c:\Users\SomeUser"), it might not work on Macs or Linux computers. Be sure to use some of the File class' built in static properties when you can, like these:
File.applicationStorageDirectory—a storage directory unique to each installed AIR application
File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)
File.desktopDirectory—the user's desktop directory
File.documentsDirectory—the user's documents directory
File.userDirectory—the user directory

Resources