Random Qt Questions for First Application Release: QThread blocking and UTF-8 labels
-
Background: I'm currently working on my first Qt application and plan to release the first version at the end of the week. The source code is at https://github.com/squinky86/STIGQter and the nightly build is currently at http://www.stigqter.com/STIGQter-nightly.zip
Issue1: When I create a new QThread() on a button press initiated by the button clicked() signal, the gui stays responsive and processes the event with a nice progress bar of what happens (eg: run the nightly and click "import CCIs" then "Download Quarterly"). But when I create a thread from the menu triggered() signal, the gui does not respond until the thread completes.
Example of STIG download thread creation (this works and does not block the GUI): https://github.com/squinky86/STIGQter/blob/master/src/stigqter.cpp#L583
Example of converting the STIGs to HTML (this blocks the GUI until the thread is complete):
https://github.com/squinky86/STIGQter/blob/master/src/stigqter.cpp#L701I've noticed that if I swap the code around, then the issue is reproducable (IE: the DownloadSTIGs() function blocks the app until it's done).
Any ideas on what I'm doing wrong when creating the QThread from a menu triggered() event?
Issue 2: If you walked through the above, you may have noticed that the progress bar status label had weird symbols at the end of it. Indeed, the horizontal ellipsis character is not showing properly in the QLabel: https://github.com/squinky86/STIGQter/blob/master/src/workerstigdownload.cpp#L60
Any ideas on why UTF characters aren't working right?
Question 3: Do you see anything I completely botched and should go fix or learn more on?
TIA!
-
@squinky86 said in Random Qt Questions for First Application Release: QThread blocking and UTF-8 labels:
Any ideas on what I'm doing wrong when creating the QThread from a menu triggered() event?
Your
WorkerHTML
object has not been moved to the new thread.Any ideas on why UTF characters aren't working right?
What encoding is your .cpp file saved in?
Question 3: Do you see anything I completely botched and should go fix or learn more on?
That's a very very broad question :)
-
@JKSH said in Random Qt Questions for First Application Release: QThread blocking and UTF-8 labels:
Your
WorkerHTML
object has not been moved to the new thread.That got it! I feel dumb now.
What encoding is your .cpp file saved in?
$ file workerstigdownload.cpp workerstigdownload.cpp: C source, UTF-8 Unicode text, with CRLF line terminators
Question 3: Do you see anything I completely botched and should go fix or learn more on?
That's a very very broad question :)
That bad, huh? ;)
I marked your answer as the right one since you were able to resolve the most pressing issue. Thanks so much for your help!
-
@squinky86 said in Random Qt Questions for First Application Release: QThread blocking and UTF-8 labels:
workerstigdownload.cpp: C source, UTF-8 Unicode text, with CRLF line terminators
I'm not sure why the ellipses isn't showing properly.
Try explicitly marking that string as a UTF-8 literal:
u8"Extracting and adding STIGs…"
or creating the string withQString::fromUtf8()
See https://docs.microsoft.com/en-us/cpp/cpp/string-and-character-literals-cpp?view=vs-2019
That bad, huh? ;)
Sorry! I wasn't trying to say that there were too many problems in your code 😂 I meant: the project is quite big — if you ask us if we see any issues, we wouldn't have a good place to start looking.
Your original question was easy to answer because you described a specific problem and you told us where to look.