Change font sizes of a QFileDialog in QT - android

I am developing an app on android platform using QT. When I am using the FileDialog of the app to open a file on the mobile phone, I find the font size is too small for my finger to select a folder. How can I make the font size larger?
I tried the following code, but the font size doesn't change.
this->setStyleSheet("QTreeView {font: 40pt \"Arial\";}");
QString dir = QFileDialog::getExistingDirectory(NULL,"","/mnt/sdcard/test/");
My code is finally changed to this, but the font still doesn't change:
void MainWindow::on_pushButton_clicked()
{
QFileDialog *fdiag = new QFileDialog;
fdiag->setStyleSheet("QTreeView {font: 40pt \"Arial\";}"); // QFileDialog
// QString dir = QFileDialog::getExistingDirectory(this,"","/mnt/sdcard/test/",QFileDialog::DontUseNativeDialog);
QString dir = fdiag->getExistingDirectory(this,QString(),"/mnt/sdcard/test/",QFileDialog::DontUseNativeDialog);
model = new QFileSystemModel();
filesPath = dir;
model->setRootPath(dir);

Related

Why does the Android version contain robot artifacts?

For a robot simulation I use a csv file with data. I read data as follows:
string dbPath = ""; string realPath; // Android string oriPath = System.IO.Path.Combine(Application.streamingAssetsPath, "Data.csv");
// Android only use WWW to read file
WWW reader = new WWW(oriPath);
while (!reader.isDone) { }
realPath = Application.persistentDataPath + "/db";
System.IO.File.WriteAllBytes(realPath, reader.bytes);
dbPath = realPath;
using (StreamReader sr = new StreamReader(dbPath))
{...}
In the Unity Editor version the simulation works as expected but on Android the arm ofthe robot moves in a strange way as you can see in the videos. I compared the two db files (on the Windows and Android paths) and the content is identical. What could be the reason of the strange movemenz?
Editor https://streamable.com/7z4qob Android https://streamable.com/rv4nm2
Thank you!
To get StreamingAssets WWW you need to add prefix jar:file:///
To get Application.persistentDataPath you need to add prefix file:///
If files are identical then problem is not in getFile code, why did you provide it?

[android ndk]How can I get absoulte path of files in asset folder?

I'm using ftgles library on android native app.
but i can't rendering a text.
this is my source code.
unsigned char* buff;
unsigned long size;
buff = GLManager::getInstance()->texture()->loadFontFromAssets("NanumGothic.ttf", &size);
font = new FTBufferFont(buff, size);
I think this code is wrong.
so I'm trying to
change this code
font = new FTBufferFont(buff, size);
to
font = new FTBufferFont("filePath");
but I don't know the absolute path of assets folder's file
could you teach me how to get assets folder's file absolute path?
Assets are not files, and you cannot use fopen() for them, which FTBufferFont(const char*) does under the hood. But you can extract an asset to a regular file if you wish, especially if you need this for debugging your code.

Xamarin Forms - Saving Files (Environment.SpecialFolder.Personal does not work)

i'm having a small issue with Xamarin.Forms
This works -
Java.IO.File path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim);
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(System.IO.Path.Combine(path.AbsolutePath, "dsdsd.txt"), false))
{
sw.WriteLine("yoyoyoyoy");
sw.Close();
}
However , using the XF Folder options as in "Working With Files" Guide ..The file is not created
var fPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string filePath = Path.Combine(fpath, "dsdsd.txt");
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(filePath, false))
{
sw.WriteLine("yoyoyoyoy");
sw.Close();
}
Any idea what is causing this issue ?
I would prefer to use my App folder instead of a public one .
I did a test on the paths :
With Xamarin Environment :
/data/data/TestApp.Droid/files/dsdsd.txt (Does not work)
With Android Path :
/storage/emulated/0/DCIM/dsdsd.txt (works)
My Actual app Folder path (When i browse using pc) :
\Phone\Android\data\TestApp.Droid\files

Unity3D create iTextSharp PDF in Android

I am making a report in Unity3D with iTextSharp. When I start app from Unity it creates PDF and works perfect. But when I build App on Android device, I have a problem with creating font. Here is what I do:
BaseFont bf = BaseFont.CreateFont(System.IO.Path.Combine(Application.streamingAssetsPath, "ADOBEARABIC-BOLD_0.OTF"), BaseFont.IDENTITY_H, false);
As I have seen, the first parameter for font creation is the path to the font. My font is in /Assets/StreamingAssets/ folder.
When I try to load it with WWW class, it can find it, but when I give just the path to the creator it won't work.
Any idea what should I do? Or is there any other way to create a font that supports Arabic characters?
EDIT:
Ok, I have somehow managed to get to the font. First I copy font from Assets to the root of the APP:
IEnumerator CopyFiles()
{
string fromPath = Application.streamingAssetsPath + "/";
string toPath = Application.persistentDataPath + "/";
string filesNamesToCopy = "ADOBEARABIC-BOLD_0.OTF";
WWW www1 = new WWW(fromPath + filesNamesToCopy);
yield return www1;
File.WriteAllBytes(toPath + filesNamesToCopy , www1.bytes);
}
And then I make BaseFont:
BaseFont bf = BaseFont.CreateFont(System.IO.Path.Combine(Application.persistentDataPath, "ADOBEARABIC-BOLD_0.OTF"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Now I get new error when try to build on Android device:
ArgumentException: Encoding name 'windows-1252' not supported
Parameter: name
You have to put some DLL files to project folder. Which one depends what encoding you have to use.
http://answers.unity3d.com/questions/42955/codepage-1252-not-supported-works-in-editor-but-no.html

Load an external text. Works on my computer, but not on app

I'm creating an app for Air 3.8 on Flash CS6. When I click on info_btn, the programm load an external textfile (here test.txt) and shows it in my dynamic text field (here info_txt).
It works when I CRTL+Enter, but not on my android device when I test the .apk file I created. I'm sure the reason is that the test.txt is not compiled in the apk, but I don't know how to change that. If you guys can help, it would be great.
Here is my code, if it can help:
var fl_TextLoader_3:URLLoader = new URLLoader();
var fl_TextURLRequest_3:URLRequest = new URLRequest("textes/test.txt");
fl_TextLoader_3.addEventListener(Event.COMPLETE, fl_CompleteHandler_3);
function fl_CompleteHandler_3(event:Event):void
{
var textData:String = new String(fl_TextLoader_3.data);
info_txt.text = textData;
}
info_btn.addEventListener(MouseEvent.CLICK, fl_infotxt);
function fl_infotxt(Event:MouseEvent):void {
fl_TextLoader_3.load(fl_TextURLRequest_3);
}
Usually mobile AIR projects will have an assets folder -- they do in Flash Builder and Flash Develop IDEs, so I assume CS6 has something similar.
The assets folder is where images and app icons go that will be delivered in the .apk. You can put any files and folders you want in there, including your text files. To package your text file into the .apk, you could create a assets/textes folder and put your test.txt in it.
Then the URL you would need in your code would be:
var fl_TextURLRequest_3:URLRequest = new URLRequest("assets/textes/test.txt");

Categories

Resources