how to open a file in my qt app via double clicking on it
-
@_-mohamed-_
So why not debug outURL
and the file path fromQFile file
for yourself? Do you mean that filename really has????
in it??@JonB no the real file name is "عربي.txt" but i can't get the real name from app's argument
-
@JonB no the real file name is "عربي.txt" but i can't get the real name from app's argument
@_-mohamed-_
Look atfile.errorString()
when thefile.open()
fails. And print outURL
andfile.fileName()
. -
@_-mohamed-_
Look atfile.errorString()
when thefile.open()
fails. And print outURL
andfile.fileName()
.@JonB i printed the URL and i got (C:\Users\moham\OneDrive\Desktop????.txt) as i said in the previous post
Sofile.open ()
can't open a strange text (????.txt) -
@JonB i printed the URL and i got (C:\Users\moham\OneDrive\Desktop????.txt) as i said in the previous post
Sofile.open ()
can't open a strange text (????.txt)@_-mohamed-_ said in how to open a file in my qt app via double clicking on it:
i printed the URL and i got (C:\Users\moham\OneDrive\Desktop????.txt) as i said in the previous post
You must not print non-ascii characters on a windows console - windows is too stupid for this. You QMessageBox or similar.
-
@_-mohamed-_ said in how to open a file in my qt app via double clicking on it:
i printed the URL and i got (C:\Users\moham\OneDrive\Desktop????.txt) as i said in the previous post
You must not print non-ascii characters on a windows console - windows is too stupid for this. You QMessageBox or similar.
@Christian-Ehrlicher I have set the text in QTextEdit using
ui->TextEdit->setPlainText (URL)
-
@Christian-Ehrlicher I have set the text in QTextEdit using
ui->TextEdit->setPlainText (URL)
@_-mohamed-_
I said:Look at
file.errorString()
when thefile.open()
fails. -
@_-mohamed-_
I said:Look at
file.errorString()
when thefile.open()
fails.@JonB why? I said that
file.open()
fail because the path is incorrectok now I tried
file.errorString()
and it returnsThe filename, directory name, or volume label syntax is incorrect.
-
I tried to open the same file with all text editors on my computer like (notepad++, VScode, Pycharm, Qt creator...) And they all opened the file successfully, is the problem in Qt?
-
I got a new problem when i override dropEvent function in QTextEdit
I usedevent->mimedata()->urls->at (0)
to get the url of the droped fileBut i got the same problem which is in arabic letters files name i got questions marks instade of the real file name(?????)
-
I got a new problem when i override dropEvent function in QTextEdit
I usedevent->mimedata()->urls->at (0)
to get the url of the droped fileBut i got the same problem which is in arabic letters files name i got questions marks instade of the real file name(?????)
@_-mohamed-_
How do you know that? @Christian-Ehrlicher wrote earlierYou must not print non-ascii characters on a windows console - windows is too stupid for this. You QMessageBox or similar.
Did you act on that? It is not clear to me how you are outputting this string, have you looked at it on a
QMessageBox
or aQLabel
, or have you used the debugger to check what the actual bytes are in the string? -
@_-mohamed-_
How do you know that? @Christian-Ehrlicher wrote earlierYou must not print non-ascii characters on a windows console - windows is too stupid for this. You QMessageBox or similar.
Did you act on that? It is not clear to me how you are outputting this string, have you looked at it on a
QMessageBox
or aQLabel
, or have you used the debugger to check what the actual bytes are in the string?@JonB
Oh it's my fault this time, I usedqDebug()
to see the output, Sorry
now I usedQMessageBox
and it works(i meandropEvent()
function)Thanks for your alert!
-
I found a solution to this problem
the URL is coming from the system, so the problem with the systemI fixed that problem by enabling UTF-8 for windows by following these steps:
• Open Control Panel
• Click on Clock and Region
• Click on Region
• Go to Administrative tab
• Click on Change system locale...
• Click on Beta: Use Unicode UTF-8 for worldwide language support check box.
• Then when you restart your computer the problem will disappear :)if you have any other solution please tell me