Hello everybody:

I’m learning to code with C++ and QT and I’m having a problem that I can’t solve. I’ll try to explain myself clearly.

I’m working with an example I found, it creates a simple window with several buttons that work ok. I made another window and I want it to appear when button “hacer algo” is clicked.

The code compiles ok and it executes opening the principal window, but I get the following errors in a cmd window:
“Object::connect: No such slot miApVentana::doSomething(argc, argv) in ..\ApVentana\ApVentana.cpp
Object::connect: (sender name: ‘boton_haceralgo’)
Object::connect: (receiver name: ‘ApVentana’)”

It works correctly except that button.

I attach the code, sorry some names and comments are in Spanish but it’s quite clear. I’m having problems uploading the code. I’ll paste it below. I work with Qt SDK 2010.04 on Windows XP.

Thank you very much for your help.

Regards
----------------------------------------------------
ApVentana.pro
CONFIG = qt
HEADERS = ApVentana.h ventana2.h
SOURCES = ApVentana.cpp ventana2.cpp main.cpp
FORMS = ApVentana.ui ventana2.ui
# install
target.path = ApVentana
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
sources.path = .
INSTALLS += target sources
--------------------------------------------Apventana.h

#ifndef APVENTANA_H
#define APVENTANA_H
#include "ui_ApVentana.h"
class miApVentana : public QWidget, private Ui::ApVentana
{
Q_OBJECT
//Constructor
public:
miApVentana(QWidget *parent = 0);
//Son los métodos de cada uno de los botones
public slots:
void getPath();
int doSomething(int argc, char *argv[]);
void clear();
void about();
};
#endif // APVENTANA_H

----------------------------------------Ventana2.h
#ifndef VENTANA2_H
#define VENTANA2_H
#include "ui_ventana2.h"
class ventanina : public QWidget, private Ui::ventana2
{
Q_OBJECT
public:
ventanina(QWidget *parent = 0);
public slots:
void Volver();
};
#endif // VENTANA2_H

-------------------------------------ApVentana.cpp
#include <QtGui>
#include <QApplication>
#include "ApVentana.h"
#include "ventana2.h"
// if we include <QtGui> there is no need to include every class used: <QString>, <QFileDialog>,...
miApVentana::miApVentana(QWidget *parent)
{
setupUi(this); // this sets up GUI
// signals/slots mechanism in action
connect( boton_explorar, SIGNAL( clicked() ), this, SLOT( getPath() ) );
connect( boton_limpiar, SIGNAL( clicked() ), this, SLOT( clear() ) );
connect( boton_informacion, SIGNAL( clicked() ), this, SLOT( about() ) );
connect( boton_haceralgo, SIGNAL(clicked()), this, SLOT ( doSomething(argc, argv)));
}
//Función del botón explorar
void miApVentana::getPath()
{
QString path;
path = QFileDialog::getOpenFileName(
this,
"Escoge un archivo para abrir",
QString::null,
QString::null);
texto_explorar->setText( path );
}
//Función del botón Limpiar
void miApVentana::clear()
{
texto_editar->clear();
}
//Función del botón Información
void miApVentana::about()
{
QMessageBox::about(this,"About myQtApp",
"This app was coded for educational purposes.\n"
"Number 1 is: " + QString::number(spinBox1->value()) + "\n\n"
"Bye.\n");
}
int miApVentana::doSomething(int argc, char *argv[])
{
QApplication app(argc, argv);
ventanina *dialog = new ventanina;
dialog->show();
return app.exec();
}

----------------------------------Ventana2.cpp
#include <QtGui>
#include "ventana2.h"
// if we include <QtGui> there is no need to include every class used: <QString>, <QFileDialog>,...
ventanina::ventanina(QWidget *parent)
{
setupUi(this); // this sets up GUI
// signals/slots mechanism in action
connect( boton_volver, SIGNAL( clicked() ), this, SLOT( Volver() ) );
}
void ventanina::Volver()
{
textEdit->clear();
}

--------------------------------Main.cpp
#include <QApplication>
#include "ApVentana.h"
#include "ventana2.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
miApVentana *dialog = new miApVentana;
dialog->show();
return app.exec();
}