Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    how to select file from a QThread

    General and Desktop
    4
    11
    2045
    Loading More Posts
    • 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
      xalisonx last edited by xalisonx

      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 Reply Quote 0
      • M
        mcosta last edited by

        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 Reply Quote 0
        • X
          xalisonx @mcosta last edited by

          @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 Reply Quote 0
          • M
            mcosta @xalisonx last edited by

            @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 Reply Quote 0
            • X
              xalisonx @mcosta last edited by

              @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 Reply Quote 0
              • M
                mcosta last edited by

                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 Reply Quote 0
                • M
                  mcosta last edited by

                  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 Reply Quote 0
                  • Malek_Khlif
                    Malek_Khlif last edited by

                    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 Reply Quote 0
                    • X
                      xalisonx @Malek_Khlif last edited by

                      @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 Reply Quote 0
                      • X
                        xalisonx @mcosta last edited by

                        @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 Reply Quote 0
                        • SGaist
                          SGaist Lifetime Qt Champion last edited by

                          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 Reply Quote 0
                          • First post
                            Last post