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. Using singals and slots in an efficient way
Forum Updated to NodeBB v4.3 + New Features

Using singals and slots in an efficient way

Scheduled Pinned Locked Moved Solved General and Desktop
qtcreatorline editsignals & slotsdirectly
4 Posts 2 Posters 1.4k 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.
  • L Offline
    L Offline
    Lasith
    wrote on 2 Dec 2017, 03:52 last edited by
    #1

    In my qt c++ application I have 4 interfaces! The first interface takes a value through a line edit and I want to send it to the last interface(4th interface) file(CPP file). Currently I send it using signals and slots through interface 2 and 3 to the 4th interface! Is there any way to send the variable value taken from line edit directly from 1st interface file to the 4th interface file?

    D 1 Reply Last reply 2 Dec 2017, 05:31
    0
    • L Lasith
      2 Dec 2017, 03:52

      In my qt c++ application I have 4 interfaces! The first interface takes a value through a line edit and I want to send it to the last interface(4th interface) file(CPP file). Currently I send it using signals and slots through interface 2 and 3 to the 4th interface! Is there any way to send the variable value taken from line edit directly from 1st interface file to the 4th interface file?

      D Offline
      D Offline
      dream_captain
      wrote on 2 Dec 2017, 05:31 last edited by dream_captain 12 Feb 2017, 05:38
      #2

      @Lasith
      I assume you're using a signal forwarding (signal to signal connection).

      It not that costly as you think, especially with implicitly shared container (QString in your case).

      From documentation:
      it's much less overhead than any new or delete operation, for example. As soon as you perform a string, vector or list operation that behind the scene requires new or delete, the signals and slots overhead is only responsible for a very small proportion of the complete function call costs

      Also, if you can get a pointer to 4th interface from your 1st, you can make a connection without signal forwarding.

      L 1 Reply Last reply 2 Dec 2017, 07:20
      2
      • D dream_captain
        2 Dec 2017, 05:31

        @Lasith
        I assume you're using a signal forwarding (signal to signal connection).

        It not that costly as you think, especially with implicitly shared container (QString in your case).

        From documentation:
        it's much less overhead than any new or delete operation, for example. As soon as you perform a string, vector or list operation that behind the scene requires new or delete, the signals and slots overhead is only responsible for a very small proportion of the complete function call costs

        Also, if you can get a pointer to 4th interface from your 1st, you can make a connection without signal forwarding.

        L Offline
        L Offline
        Lasith
        wrote on 2 Dec 2017, 07:20 last edited by
        #3

        @dream_captain You mean if we have 10 interfaces inorder to send a value from 1st interface to the 10th interface we have to create signal slot pairs in each interface? :O

        D 1 Reply Last reply 2 Dec 2017, 08:48
        0
        • L Lasith
          2 Dec 2017, 07:20

          @dream_captain You mean if we have 10 interfaces inorder to send a value from 1st interface to the 10th interface we have to create signal slot pairs in each interface? :O

          D Offline
          D Offline
          dream_captain
          wrote on 2 Dec 2017, 08:48 last edited by dream_captain 12 Feb 2017, 08:55
          #4

          @Lasith
          No, in this case use QSignalMapper.

          1 Reply Last reply
          0

          1/4

          2 Dec 2017, 03:52

          • Login

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