Error in event Clicked on PushButton!



  • Hello , I am starting on Qt , I created a new design for test, inserted a botoão and am wondering associate the click event to an action (function) , but I'm not getting , compiling happens this error:

    • Error: 'Clicked' was not declared in this scope

    • following code: MainWindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    connect(ui->pushButton,signal(Clicked()),
    this,
    SLOT(close()));
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }


  • Qt Champions 2016

    @Vicius_Souza said:
    Hi and welcome
    clicked()
    with small c

    the new syntax will catch such things
    connect(ui->pushButton, &QPushButton::clicked, this, &QMainwindow::close);
    (from memory, might be errors :)

    https://wiki.qt.io/New_Signal_Slot_Syntax



  • Perfect thank you !


Log in to reply
 

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