Results 1 to 3 of 3

Thread: Signal with pointer passes only the first value

  1. #1
    Join Date
    May 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Signal with pointer passes only the first value

    Hey People

    As the Caption already meantions is my problem that i send a signal from one widget to another one passing 3 pointers to arrays. but in the slot i get only the first value af each array.
    That means in detail:

    i have a widget that has for example:

    double* freq = new double[10000];
    float* re = new float[10000];
    float* im = new float[10000];

    i create a SIGNAL that looks like this:

    void speccdata_send(double*, float*, float*);

    and i emit it like this:

    emit speccdata_send(freq, re, im);

    the pointer seems to "arrive" at the SLOT too but only the first value of the 3 arrays is correct the rest is 0 .
    Does anyone have an idea what my mistake is?

    Thanks
    Basti

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Signal with pointer passes only the first value

    I suspect you are using threads, right?

    By the way, why don't you use QVector or QList instead of those C-arrays?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Signal with pointer passes only the first value

    You better follow Wysota's advices,

    And when you work with c-style arrays you are more secure if you send the size too, not let the receiver slot (which may be modified by someone else in the future) guess that the size didn't change (and if you pass the sizes, you avoid the use "magic numbers" for the size of arrays)

Similar Threads

  1. Replies: 3
    Last Post: 30th July 2010, 16:34
  2. Replies: 1
    Last Post: 7th December 2009, 18:49
  3. signal mapping on pushbutton signal clicked
    By wagmare in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 07:54
  4. Replies: 4
    Last Post: 16th November 2008, 13:53
  5. Passing a pointer in Signal/Slot Connection
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 6th November 2007, 19:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.