Array not sent from signal and slot

  • I want to send an array from one form(MainWindow) to another form(Dialog) upon a button click! Though the array seems to be sent it returns a wrong value! Following are my codes!


    signals:void sendArray(int a[]);


    void MainWindow::on_pushButton_clicked()
    int a[] = {1,2,3};
    Dialog dialog1;
    emit sendArray(a);



    public slots:
    void receiveArray(int a[]);


    void Dialog::receiveArray(int a[]){
    int value=a[0];
    QString value1=QString::number(value);

    When the program is run(no compile errors occur) and the button is clicked though 1 (0th index of the array) should printed on the label in Dialog form a wrong value 8441124 is printed. How can I correct this?

  • I found the solution myself! Use QList<int> instead of normal arrays :)

  • Lifetime Qt Champion

    old type c array can also work.
    Its just a matter of what is registered already.
    You can register your own types.

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.