code_err
8th October 2011, 18:08
I was trying to find solution on forum but couldn't. The problem is i connected SIGNAL from QComboBox with QPushButton SLOT. I want it to be disabled after changing item from combo list but it doesn't work. When i connect this same SIGNAL with qApp quit() SLOT it works.
QObject::connect(&combo, SIGNAL(activated(int)), &button, SLOT(setDisabled()));
Button inherits this SLOT from QWidget but i don't know why in the Qt Designer i cannot see this SLOT.
#include <QApplication>
#include <QtCore>
#include <QtGui>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QWidget window;
QVBoxLayout *layout = new QVBoxLayout;
QStringList list;
list << "jeden" << "dwa" << "trzy" << "cztery" << QString::fromUtf8("pięć");
QComboBox combo;
combo.addItems(list);
QPushButton button(QString::fromUtf8("Wyłącz się do cholery"));
window.setLayout(layout);
layout->addWidget(&combo);
layout->addWidget(&button);
QObject::connect(&combo, SIGNAL(activated(int)), &button, SLOT(setDisabled(bool)));
QObject::connect(&button, SIGNAL(clicked()), qApp, SLOT(quit()));
window.show();
return app.exec();
}
it is complete main.cpp
Ok, what is wrong with this code?
QObject::connect(&combo, SIGNAL(activated(int)), &button, SLOT(setDisabled()));
Button inherits this SLOT from QWidget but i don't know why in the Qt Designer i cannot see this SLOT.
#include <QApplication>
#include <QtCore>
#include <QtGui>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QWidget window;
QVBoxLayout *layout = new QVBoxLayout;
QStringList list;
list << "jeden" << "dwa" << "trzy" << "cztery" << QString::fromUtf8("pięć");
QComboBox combo;
combo.addItems(list);
QPushButton button(QString::fromUtf8("Wyłącz się do cholery"));
window.setLayout(layout);
layout->addWidget(&combo);
layout->addWidget(&button);
QObject::connect(&combo, SIGNAL(activated(int)), &button, SLOT(setDisabled(bool)));
QObject::connect(&button, SIGNAL(clicked()), qApp, SLOT(quit()));
window.show();
return app.exec();
}
it is complete main.cpp
Ok, what is wrong with this code?