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

blocking connect()

Scheduled Pinned Locked Moved Solved General and Desktop
connectqt 5.5.0signal & slot
5 Posts 3 Posters 3.6k Views 1 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.
  • P Offline
    P Offline
    Pogi
    wrote on last edited by
    #1

    connect(&server,SIGNAL(display()),this,SLOT(display()));
    if display() signal is emitted, display() slot will be executed.
    so now i want the display() slot to block the program until it returns.
    how do i do that?
    TIA.

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Your program will block as long as display() does not return.
      There is no need to do something special to block your program, even if it sounds strange why you want it to block.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply
      0
      • jsulmJ jsulm

        Your program will block as long as display() does not return.
        There is no need to do something special to block your program, even if it sounds strange why you want it to block.

        P Offline
        P Offline
        Pogi
        wrote on last edited by Pogi
        #3

        @jsulm
        I tested it, it doesnt block the program
        emit display();
        qDebug() << "Message received!";
        output:
        Message received!
        contents of display() slot

        ive search around while waiting for answers in this thread.
        can you tell me the use of Qt::BlockingQueuedConnection?

        TIA

        1 Reply Last reply
        0
        • Chris KawaC Online
          Chris KawaC Online
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Emitting a signal in a single thread is basically calling a function, so it is blocking. The output you have can happen if "server" and "this" objects live in different threads. Is that the case?

          Qt::BlockingQueuedConnection is only useful if sender and receiver live in different threads. It makes the sender block on emit until receiver executes the slot. In a single threaded execution this is how emit behaves out of the box.

          P 1 Reply Last reply
          0
          • Chris KawaC Chris Kawa

            Emitting a signal in a single thread is basically calling a function, so it is blocking. The output you have can happen if "server" and "this" objects live in different threads. Is that the case?

            Qt::BlockingQueuedConnection is only useful if sender and receiver live in different threads. It makes the sender block on emit until receiver executes the slot. In a single threaded execution this is how emit behaves out of the box.

            P Offline
            P Offline
            Pogi
            wrote on last edited by
            #5

            @Chris-Kawa
            my sender and receiver is in different thread.
            I see! you hit all the bullseye!
            THanks guys!

            and i now understand the Qt::BlockingQueuedConnection

            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