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
Forum Updated to NodeBB v4.3 + New Features

how to select file from a QThread

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 2.5k Views 3 Watching
  • 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 12 Mar 2015, 16:18 last edited by xalisonx 3 Dec 2015, 16:18
    #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 12 Mar 2015, 16:57 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 12 Mar 2015, 17:00
      0
      • M mcosta
        12 Mar 2015, 16:57

        why you need this feature?

        GUI can be run only from main thread

        X Offline
        X Offline
        xalisonx
        wrote on 12 Mar 2015, 17:00 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 12 Mar 2015, 17:02
        0
        • X xalisonx
          12 Mar 2015, 17:00

          @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 12 Mar 2015, 17:02 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 12 Mar 2015, 17:13
          0
          • M mcosta
            12 Mar 2015, 17:02

            @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 12 Mar 2015, 17:13 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 12 Mar 2015, 17:18 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 12 Mar 2015, 17:26 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 17 Mar 2015, 08:18
                0
                • M Offline
                  M Offline
                  Malek_Khlif
                  wrote on 12 Mar 2015, 19:04 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 17 Mar 2015, 08:17
                  0
                  • M Malek_Khlif
                    12 Mar 2015, 19:04

                    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 17 Mar 2015, 08:17 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
                      12 Mar 2015, 17:26

                      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 17 Mar 2015, 08:18 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 17 Mar 2015, 08:50 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

                        1/11

                        12 Mar 2015, 16:18

                        • Login

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