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

Using singals and slots in an efficient way

Scheduled Pinned Locked Moved Solved General and Desktop
qtcreatorline editsignals & slotsdirectly
4 Posts 2 Posters 1.3k 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 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?

    dream_captainD 1 Reply Last reply
    0
    • L Lasith

      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?

      dream_captainD Offline
      dream_captainD Offline
      dream_captain
      wrote on last edited by dream_captain
      #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
      • dream_captainD dream_captain

        @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 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

        dream_captainD 1 Reply Last reply
        0
        • L Lasith

          @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

          dream_captainD Offline
          dream_captainD Offline
          dream_captain
          wrote on last edited by dream_captain
          #4

          @Lasith
          No, in this case use QSignalMapper.

          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