Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] Connecting qml signal with arguments from other qml file to qt slot
Forum Update on Monday, May 27th 2025

[Solved] Connecting qml signal with arguments from other qml file to qt slot

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 3.1k 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.
  • S Offline
    S Offline
    spode
    wrote on 22 Nov 2011, 14:34 last edited by
    #1

    Seconda.qml
    @
    Rectangle {
    signal signal_return();
    signal signal_avanti(string titolo, string argomento);

    width: lunghezza; height: altezza
    
    FinestraDelPensiero {
        id: finestra_pensiero_img
        anchors.fill: parent
        visible: false
        z: 1
    }
    

    [...]
    }
    @

    FinestraDelPensiero.qml
    @
    import QtQuick 1.0

    Rectangle {
    property int lunghezza: 1200;
    property int altezza: 800;
    property string testo: "Inserire: [Lingua d' Origine][Spazio][Lingua Finale]"

    width: lunghezza
    height: altezza
    id: finestra
    
    Image {
        id: image1
        x: 0
        y: 204
        z: 3
        source: "Avviso.png"
    }
    
    Image {
        id: image4
        x: 302
        y: 342
        width: 450
        height: 155
        source: "v.png"
    
        MouseArea {
            id: mouse_area1
            anchors.fill: parent
            onClicked: signal_avanti(testo, text_edit1.text)
        }
    }
    
    Image {
        id: image3
        x: 752
        y: 342
        width: 450
        height: 155
        source: "x.png"
    
        MouseArea {
            id: mouse_area2
            anchors.fill: parent
            onClicked:  finestra.visible = true
        }
    }
    
    Image {
        id: image5
        x: 192
        y: 89
        width: 1095
        height: 248
        scale: 0.8
        source: "alert.png"
    
        Text {
            id: text1
            x: 215
            y: 48
            text: testo
            font.bold: true
            anchors.verticalCenterOffset: -49
            anchors.verticalCenter: parent.verticalCenter
            font.pixelSize: 32
        }
    
        TextEdit {
            id: text_edit1
            x: 257
            y: 149
            width: 80
            height: 20
            text: ""
            font.pixelSize: 35
            focus: true
        }
    }
    

    }
    @

    Seconda.cpp
    @
    Seconda::Seconda(const QString creanuovasezione, QWidget *parent) :
    QWidget(parent)
    {
    view = new QDeclarativeView(this);
    view->setSource(QUrl::fromLocalFile("qml/HUVWoerterSZErinnern/Seconda.qml"));
    //impostando le proprietà: altezza, larghezza e nuova parola
    QObject *objview = view->rootObject();

    if(creanuovasezione.contains("Nuovo"))
        { objview->setProperty("inseriscinuovaparola_visibile", QVariant::fromValue(true)); }
    else
        { objview->setProperty("inseriscinuovaparola_visibile", QVariant::fromValue(false));
          objview->setProperty("currentlingue", QVariant::fromValue(creanuovasezione)); }
    
    objview->setProperty("lunghezza", QVariant::fromValue(QApplication::desktop()->geometry().width()));
    objview->setProperty("altezza", QVariant::fromValue(QApplication::desktop()->geometry().height()));
    //END impostando le proprietà: altezza, larghezza e nuova parola
    
    connect(objview, SIGNAL(signal_avanti(QString, QString)), this, SLOT(createOrDeleteNewSection(const QString, QString))); //here the error
    connect(objview, SIGNAL(signal_return()), this, SLOT(openPrimaSchermata()));
    
    view->show();
    this->showMaximized();
    

    }
    @

    how to connect the signal from FinestraDelPensiero (2nd snippet), that is used in the first snippet, to qt (3rd snippet)?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      srikanth_trulyit
      wrote on 22 Nov 2011, 16:28 last edited by
      #2

      Expose cpp as a "context property":http://doc.qt.nokia.com/4.7-snapshot/qtbinding.html#embedding-c-objects-into-qml-components say Engine. Now create a "Connections":http://doc.qt.nokia.com/latest/qml-connections.html element in Seconda.qml which is connected to the signal of interest and call the Engine slot.

      1 Reply Last reply
      0

      1/2

      22 Nov 2011, 14:34

      • Login

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