Important: Please read the Qt Code of Conduct -

using UI with signals and elements

  • hi I've been studying qt recently and i know how to use signals in fact the problem I am facing right now I've already wrote it in cpp,

    #include <QApplication>
    #include <QLineEdit>
    #include <QWidget>
    #include <QLabel>
    #include <QVBoxLayout>
    int main(int argc, char *argv[])
      QApplication a(argc, argv);
      QWidget widget;
      QLineEdit *lineEdit = new QLineEdit;
      QLabel *label = new QLabel;
      QVBoxLayout *layout = new QVBoxLayout;
            lineEdit, SIGNAL(textChanged(const QString&)),
            label, SLOT(setText(const QString&)) );
      return a.exec();

    so I'm trying to write the same program using ui so I create the same ui and right click on line edit go to slots and choose ontextchanged and it gives me this:

    #include "mainwindow.hpp"
    #include "ui_mainwindow.h"
    MainWindow::MainWindow(QWidget *parent)
      : QMainWindow(parent)
      , ui(new Ui::MainWindow)
      delete ui;
    void MainWindow::on_lineEdit_textChanged(const QString &arg1)

    i don't know what to do next. how do i connect a ui element 's signal to another slot? what should i write in this case inside the

    void MainWindow::on_lineEdit_textChanged(const QString &arg1)


  • Lifetime Qt Champion

    @nullbuil7 said in using UI with signals and elements:

    what should i write in this case inside the


    I guess? Or what is the question?

  • I found the answer here:
    It's from Qt 4.8 but still unchanged.

Log in to reply