Hello,
I'm very confused about the fact, that if I click (left mouse button) on a pushbutton, then the function connected via SLOT to the SIGNAL of pushbuttons is executed twice. Why? I want it to be executed only one time! How to avoid this behaviour?
I have created my GUI Framework by means of Qt Designer 4.5.1 and then connect the SLOTs automatically by the command "QMetaObject::connectSlotsByName(this);"
Here is the part of cpp code:
#include <iostream>
#include <time.h>
#include <QtUiTools>
#include <QtGui>
#include "mainframe.h"
#include "Vertex.h"
#include "graphicscene.h"
using namespace std;
mainFrame
::mainFrame(QWidget *parent
){
ui.setupUi(this);
ui_pushButton_START = qFindChild<QPushButton*>(this, "pushButton_START");
ui_pushButton_Select = qFindChild<QPushButton*>(this, "pushButton_Select");
ui_pushButton_Recombine = qFindChild<QPushButton*>(this, "pushButton_Recombine");
/*
connect(ui_pushButton_START, SIGNAL(clicked()), this, SLOT(on_pushButton_Recombine_clicked()));
connect(ui_pushButton_Select, SIGNAL(clicked()), this, SLOT(on_pushButton_Select_clicked()));
connect(ui_pushButton_Recombine, SIGNAL(clicked()), this, SLOT(on_pushButton_Recombine_clicked()));
*/
#include <iostream>
#include <time.h>
#include <QtUiTools>
#include <QtGui>
#include "mainframe.h"
#include "Vertex.h"
#include "graphicscene.h"
using namespace std;
mainFrame::mainFrame(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
ui_pushButton_START = qFindChild<QPushButton*>(this, "pushButton_START");
ui_pushButton_Select = qFindChild<QPushButton*>(this, "pushButton_Select");
ui_pushButton_Recombine = qFindChild<QPushButton*>(this, "pushButton_Recombine");
/*
connect(ui_pushButton_START, SIGNAL(clicked()), this, SLOT(on_pushButton_Recombine_clicked()));
connect(ui_pushButton_Select, SIGNAL(clicked()), this, SLOT(on_pushButton_Select_clicked()));
connect(ui_pushButton_Recombine, SIGNAL(clicked()), this, SLOT(on_pushButton_Recombine_clicked()));
*/
QMetaObject::connectSlotsByName(this);
To copy to clipboard, switch view to plain text mode
and here a part of header file:
{
Q_OBJECT
public:
~mainFrame();
// here the slots are declared, which are kind of sink for connected objects
private slots:
void on_pushButton_Quit_clicked();
void updateParameters();
void on_pushButton_START_clicked();
void on_pushButton_Recombine_clicked();
void on_pushButton_Select_clicked();
class mainFrame : public QMainWindow
{
Q_OBJECT
public:
mainFrame(QWidget *parent = 0);
~mainFrame();
// here the slots are declared, which are kind of sink for connected objects
private slots:
void on_pushButton_Quit_clicked();
void updateParameters();
void on_pushButton_START_clicked();
void on_pushButton_Recombine_clicked();
void on_pushButton_Select_clicked();
To copy to clipboard, switch view to plain text mode
Help me please to avoid this failure function. Thank you.
best regards,
Vitali
Bookmarks