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. how to select file from a QThread
QtWS25 Last Chance

how to select file from a QThread

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 2.5k 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.
  • X Offline
    X Offline
    xalisonx
    wrote on last edited by xalisonx
    #1

    Hi all,
    How to select a file with QFileDialog in a running QThread, and wait the result?

    I've tried with signals&slots but it's a async technique.

    Some help?
    :)

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      why you need this feature?

      GUI can be run only from main thread

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      X 1 Reply Last reply
      0
      • M mcosta

        why you need this feature?

        GUI can be run only from main thread

        X Offline
        X Offline
        xalisonx
        wrote on last edited by
        #3

        @mcosta yep, this is the problem :(
        My application implement a thread based httpserver. One service is to select a file and get the path.

        M 1 Reply Last reply
        0
        • X xalisonx

          @mcosta yep, this is the problem :(
          My application implement a thread based httpserver. One service is to select a file and get the path.

          M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          @xalisonx said:

          @mcosta yep, this is the problem :(
          My application implement a thread based httpserver. One service is to select a file and get the path.

          why multi-thread gui for that??

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          X 1 Reply Last reply
          0
          • M mcosta

            @xalisonx said:

            @mcosta yep, this is the problem :(
            My application implement a thread based httpserver. One service is to select a file and get the path.

            why multi-thread gui for that??

            X Offline
            X Offline
            xalisonx
            wrote on last edited by
            #5

            @mcosta the thread open the socket and read http request, and should get back the response..... in this case the path of a selected file!!! any tips?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mcosta
              wrote on last edited by
              #6

              http requests shall be served in few seconds otherwise you can have timeout.

              Once your problem is solved don't forget to:

              • Mark the thread as SOLVED using the Topic Tool menu
              • Vote up the answer(s) that helped you to solve the issue

              You can embed images using (http://imgur.com/) or (http://postimage.org/)

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mcosta
                wrote on last edited by
                #7

                you can send a signal to the gui when the server receives requests. the gui can open the dialog and send back the path.

                The problem is to handle correctly the requests timeout. HTTP has special code (IIRC 100) for long operation

                Once your problem is solved don't forget to:

                • Mark the thread as SOLVED using the Topic Tool menu
                • Vote up the answer(s) that helped you to solve the issue

                You can embed images using (http://imgur.com/) or (http://postimage.org/)

                X 1 Reply Last reply
                0
                • Malek_KhlifM Offline
                  Malek_KhlifM Offline
                  Malek_Khlif
                  wrote on last edited by
                  #8

                  A Gui widgets can only use it in main thread but you can use Signal-Slot with Qt::QueedConnexion if you want your widget d'ont freeze

                  I Love Qt <3

                  X 1 Reply Last reply
                  0
                  • Malek_KhlifM Malek_Khlif

                    A Gui widgets can only use it in main thread but you can use Signal-Slot with Qt::QueedConnexion if you want your widget d'ont freeze

                    X Offline
                    X Offline
                    xalisonx
                    wrote on last edited by
                    #9

                    @Malek_Khlif said:

                    A Gui widgets can only use it in main thread but you can use Signal-Slot with Qt::QueedConnexion if you want your widget d'ont freeze

                    mmmm thanks malek, can you make me an example?

                    1 Reply Last reply
                    0
                    • M mcosta

                      you can send a signal to the gui when the server receives requests. the gui can open the dialog and send back the path.

                      The problem is to handle correctly the requests timeout. HTTP has special code (IIRC 100) for long operation

                      X Offline
                      X Offline
                      xalisonx
                      wrote on last edited by
                      #10

                      @mcosta said:

                      you can send a signal to the gui when the server receives requests. the gui can open the dialog and send back the path.

                      The problem is to handle correctly the requests timeout. HTTP has special code (IIRC 100) for long operation

                      MMMMMMMM, maybe it could be a problem.... some other opinion ?

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Hi,

                        That sounds a bit like reverse logic. Can you explain your application work flow ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        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