Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Random Qt Questions for First Application Release: QThread blocking and UTF-8 labels

Random Qt Questions for First Application Release: QThread blocking and UTF-8 labels

Scheduled Pinned Locked Moved Solved General and Desktop
qthreadutf-8newbie
5 Posts 2 Posters 593 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    squinky86
    wrote on last edited by
    #1

    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#L701

    I'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!

    JKSHJ 1 Reply Last reply
    0
    • S squinky86

      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#L701

      I'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!

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by JKSH
      #2

      @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 :)

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      S 1 Reply Last reply
      4
      • JKSHJ JKSH

        @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 :)

        S Offline
        S Offline
        squinky86
        wrote on last edited by
        #3

        @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!

        JKSHJ 1 Reply Last reply
        0
        • S squinky86

          @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!

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          @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 with QString::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.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          4
          • S Offline
            S Offline
            squinky86
            wrote on last edited by
            #5

            The ellipsis are showing up correctly now that I'm using a consistent compiler for my tests.
            I still have many bugs to fix, but got the first release out the door.
            Thanks again for all of your help!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved