connect() on the line 19 returns true, all the widgets are set up properly, so the line 20 works, yet the slot is never called. Why ? Where did I do a mistake ?
#include "irc_settings.h"
#include "MainWindow.h"
#include <QtGui>
#include <QtDesigner>
dbg() << "setting up irc settings form";
QFile file(":/forms/irc_settings.ui");
file.
open(QFile::ReadOnly);
QWidget *myWidget
= builder.
load(&file,
this);
file.close();
lineEdit_new_nickname = qFindChild<QLineEdit*>(this,"lineEdit_new_nickname");
lineEdit_new_nickname->setText("foo");
listWidget_nicknames = qFindChild<QListWidget*>(this,"listWidget_nicknames");
toolButton_add_nickname = qFindChild<QToolButton*>(this,"toolButton_add_nickname");
dbg
() <<
"connecting toolButton_add_nickname to listWidget_nicknames" <<
connect(toolButton_add_nickname,
SIGNAL(triggered
(QAction*)),
this,
SLOT(slot_add_new_nickname
(QAction*)));
listWidget_nicknames->addItem(lineEdit_new_nickname->text());
layout->addWidget(myWidget);
setLayout(layout);
}
void IRC_Settings
::slot_add_new_nickname(QAction* action
) { dbg() << "adding new nickname:" << lineEdit_new_nickname->text();
listWidget_nicknames->addItem(lineEdit_new_nickname->text());
}
IRC_Settings::~IRC_Settings() {
}
#include "irc_settings.h"
#include "MainWindow.h"
#include <QtGui>
#include <QtDesigner>
IRC_Settings::IRC_Settings( QWidget *parent) : QWidget(parent) {
dbg() << "setting up irc settings form";
QFormBuilder builder;
QFile file(":/forms/irc_settings.ui");
file.open(QFile::ReadOnly);
QWidget *myWidget = builder.load(&file, this);
file.close();
lineEdit_new_nickname = qFindChild<QLineEdit*>(this,"lineEdit_new_nickname");
lineEdit_new_nickname->setText("foo");
listWidget_nicknames = qFindChild<QListWidget*>(this,"listWidget_nicknames");
toolButton_add_nickname = qFindChild<QToolButton*>(this,"toolButton_add_nickname");
dbg() << "connecting toolButton_add_nickname to listWidget_nicknames" << connect(toolButton_add_nickname,SIGNAL(triggered(QAction*)),this,SLOT(slot_add_new_nickname(QAction*)));
listWidget_nicknames->addItem(lineEdit_new_nickname->text());
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(myWidget);
setLayout(layout);
}
void IRC_Settings::slot_add_new_nickname(QAction* action) {
dbg() << "adding new nickname:" << lineEdit_new_nickname->text();
listWidget_nicknames->addItem(lineEdit_new_nickname->text());
}
IRC_Settings::~IRC_Settings() {
}
To copy to clipboard, switch view to plain text mode
Bookmarks