my slots don't appear in the signal slot editor
I don't mind coding my own connect statements but I am trying to learn Qt designer
This code works!
Code:
// part of the .h file
private:
Ui::ECalc1Class ui;
private slots: // my methods...yes I tried public:
void addClicked();
void subClicked();
void mulClicked();
void divClicked();
____________________________________________
#include "ecalc1.h"
#include <QMessageBox>
{
ui.setupUi(this);
connect( ui.pushButtonAdd, SIGNAL(clicked()), this, SLOT(addClicked()) );
connect( ui.pushButtonSub, SIGNAL(clicked()), this, SLOT(subClicked()) );
connect( ui.pushButtonMul, SIGNAL(clicked()), this, SLOT(mulClicked()) );
connect( ui.pushButtonDiv, SIGNAL(clicked()), this, SLOT(divClicked()) );
}
Re: my slots don't appear in the signal slot editor
QtDesigner doesn't pull the slots from your source code, but from the ui file. So if you want to access them via designer, you'll need to right click an object and use the "change signals/slots" menu item. Add them there and they will appear.
BTW, the generated code by designer calls connectSlotsByName() which means that if you have a function like "void on_button1_clicked();" you don't need to connect() it, as it'll be done for you when you call setupui(). Saves doing it yourself.
Re: my slots don't appear in the signal slot editor
slots will be grayed out if the slot is incompatible with the signal. For example, a slot expecting an int will not accept a signal that emits a char *
All connect statements generated by designer will be present in the header file and executed when setupui is called.
Re: my slots don't appear in the signal slot editor
OK but why do these slots show up as choices in the Qt C++ signal slot tab below???
and with "my" connect statement tha works, how do I fix the other 3
for subtract, mutiply and divide
connect(ui.pushButtonAdd,SIGNAL(clicked()),this,SL OT(addClicked()));
QAbstratButton has
Signals
*
void clicked ( bool checked = false ) argument optional
*
void pressed ()
*
void released ()
*
void toggled ( bool checked )
*
1 signal inherited from QWidget
*
1 signal inherited from QObject
My slots are all void void
Re: my slots don't appear in the signal slot editor
Your slots shouldn't be all void void. If there are no parameters, the parameter list should be empty, otherwise the slots will be grayed out in designer.
If you create a slot in designer and name it "foo()", then it will allow you to assign the clicked() event to that slot using the "Edit signals/slots" editor (ie, you drag a line from the button to whatever)
If you are still having problems, post your project.
Re: my slots don't appear in the signal slot editor
I have tar'ed and gzip'ed the workspace (Eclipse) for the project attached
If you don't have Eclipse with Qt designer plugin, I can export the files and "retar"
Re: my slots don't appear in the signal slot editor
You seem to have forgotten to attach the project.
Secondly, have you tried to open the .ui file in QtDesigner itself rather than the Eclipse plugin to make sure it isn't a bug in the plugin?
Re: my slots don't appear in the signal slot editor
may be this:
Code:
clicked(bool c = false)
? void is actually not equal to default argument.
Re: my slots don't appear in the signal slot editor
Please edit your posts if you have anything to add instead of replying to yourself.
Re: my slots don't appear in the signal slot editor
wysota:
just curious...are you a Nokia (formerly Trolltech) employee??
Tanuli-no:
thanks! clicked(bool c = false) occurred to me even though it is really unnecessary.
Come to think of it,
he whole original parameter spec should really be used anyway!
Assuming that is correct (I think it is) why are the user slots appearing at the bottom dialog (tab) and not at the top dialog (F4/icon)?
The following compiled and ran but with warning:
Object::connect: No such signal QPushButton::clicked(bool c) in trycalc.cpp:7
Object::connect: (sender name: 'pushButtonAdd')
Object::connect: (receiver name: 'trycalcClass')
Code:
#ifndef TRYCALC_H
#define TRYCALC_H
#include <QtGui/QWidget>
#include "ui_trycalc.h"
{
Q_OBJECT
public:
~trycalc();
private:
Ui::trycalcClass ui;
public slots:
void addClicked(bool c = false);
void subClicked(bool c = false);
void mulClicked(bool c = false);
void divClicked(bool c = false);
};
#endif // TRYCALC_H
#include "trycalc.h"
#include <QMessageBox>
{
ui.setupUi(this);
connect(ui.pushButtonAdd,SIGNAL(clicked(bool c)),this,SLOT(addClicked(bool c;
}
trycalc::~trycalc()
{
}
//
void trycalc::addClicked(bool c)
{
QString qstring1
= ui.
lineEdit->text
();
QString qstring2
= ui.
lineEdit_2->text
();
bool ok1 = true;
bool ok2 = true;
float f1 = qstring1.toFloat(&ok1);
float f2 = qstring2.toFloat(&ok2);
if( qstring1.length() == 0
|| qstring2.length() == 0
|| !ok1
|| !ok2)
{
"missing or bad entry",
mb.exec();
ui.lineEdit->clear();
ui.lineEdit_2->clear();
ui.lineEdit_3->clear();
return;
}
float f3 = f1 + f2;
qstring3.setNum(f3);
ui.lineEdit_3->setText(qstring3);
}
void trycalc::subClicked(bool c)
{
QString qstring1
= ui.
lineEdit->text
();
QString qstring2
= ui.
lineEdit_2->text
();
bool ok1 = true;
bool ok2 = true;
float f1 = qstring1.toFloat(&ok1);
float f2 = qstring2.toFloat(&ok2);
if( qstring1.length() == 0
|| qstring2.length() == 0
|| !ok1
|| !ok2)
{
"missing or bad entry",
mb.exec();
ui.lineEdit->clear();
ui.lineEdit_2->clear();
ui.lineEdit_3->clear();
return;
}
float f3 = f1 - f2;
qstring3.setNum(f3);
ui.lineEdit_3->setText(qstring3);
}
void trycalc::mulClicked(bool c)
{
QString qstring1
= ui.
lineEdit->text
();
QString qstring2
= ui.
lineEdit_2->text
();
bool ok1 = true;
bool ok2 = true;
float f1 = qstring1.toFloat(&ok1);
float f2 = qstring2.toFloat(&ok2);
if( qstring1.length() == 0
|| qstring2.length() == 0
|| !ok1
|| !ok2)
{
"missing or bad entry",
mb.exec();
ui.lineEdit->clear();
ui.lineEdit_2->clear();
ui.lineEdit_3->clear();
return;
}
float f3 = f1 * f2;
qstring3.setNum(f3);
ui.lineEdit_3->setText(qstring3);
}
void trycalc::divClicked(bool c)
{
QString qstring1
= ui.
lineEdit->text
();
QString qstring2
= ui.
lineEdit_2->text
();
bool ok1 = true;
bool ok2 = true;
float f1 = qstring1.toFloat(&ok1);
float f2 = qstring2.toFloat(&ok2);
if( qstring1.length() == 0
|| qstring2.length() == 0
|| !ok1
|| !ok2
|| f2==0.)
{
"missing or bad entry",
mb.exec();
ui.lineEdit->clear();
ui.lineEdit_2->clear();
ui.lineEdit_3->clear();
return;
}
float f3;
if (f2 != 0.) f3 = f1 / f2;
qstring3.setNum(f3);
ui.lineEdit_3->setText(qstring3);
}
Re: my slots don't appear in the signal slot editor
Quote:
Originally Posted by
landonmkelsey
wysota:
just curious...are you a Nokia (formerly Trolltech) employee??
No, I'm not.
Re: my slots don't appear in the signal slot editor
What is this?
Code:
void addClicked(bool c = false);
void subClicked(bool c = false);
void mulClicked(bool c = false);
void divClicked(bool c = false);
If you don't care about the state, it should be:
Code:
void addClicked();
void subClicked();
void mulClicked();
void divClicked();
As mentioned previously.
Re: my slots don't appear in the signal slot editor
somebody recommended a fix and I was giving it a shot
Your recommendation describes my original code.
My original code compiled and ran without warning/error.
Re: my slots don't appear in the signal slot editor
1 Attachment(s)
Re: my slots don't appear in the signal slot editor
attached but....one could( in 30 seconds), simply drag 3 lineedtit controls and a pushbutton onto the designer surface and try what is supposed to be the purpose of the designer
code produced from a graphical start...the slots are coded, connects are coded, etc
the original question. was:
Re: my slots don't appear in the signal slot editor
So what's the problem exactly? The slots you added are available in Designer's signal/slot editor. Isn't it what you wanted?
Re: my slots don't appear in the signal slot editor
from first post
(1) why are all slots grayed out in the "drag red line" editor from F4 or
the edit signals/slots icon above but
These "grayed" slots are NOT grayed out in the "C++ Signals/Slotst" editor tab below
Re: my slots don't appear in the signal slot editor
Quote:
Originally Posted by
landonmkelsey
attached but....one could( in 30 seconds), simply drag 3 lineedtit controls and a pushbutton onto the designer surface and try what is supposed to be the purpose of the designer
Yes, and we said that worked fine for us, hence the reason for wanting YOUR ui file which you said doesn't work.
I've just opened your ui file, deleted the connections, and then use the red line signal slot editor to connect the buttons to your appropriate functions (addClicked, etc) with no problems at all. I didn't have to use the bottom box at all.
So, whats the problem? You ARE selecting a signal before attempting to select a slot? Otherwise the slots WILL be grayed out as they are not usable at that stage.
Re: my slots don't appear in the signal slot editor
I give up!
thanks anyway!
Re: my slots don't appear in the signal slot editor
Maybe you are using some very old version of Designer which had that functionality broken?
Re: my slots don't appear in the signal slot editor
I have the latest Fedora Linux 12 updates
same for eclipse and the plugin
I'll try it again after the next update...thanks!
Next will probably be 4.6!
BTW
[qt4@localhost Downloads]$ rpm -qa|grep qt
poppler-qt4-0.12.2-1.fc12.i686
qt-4.5.3-9.fc12.i686
qt-sqlite-4.5.3-9.fc12.i686
PackageKit-qt-0.5.4-0.4.20091029git.fc12.i686
qwtplot3d-qt4-0.2.7-9.fc12.i686
qtoctave-0.8.1-0.20080826.svn165.fc12.i686
qt-x11-4.5.3-9.fc12.i686
avahi-qt3-0.6.25-5.fc12.i686
qt-qsa-1.1.5-7.fc12.i686
qt-devel-4.5.3-9.fc12.i686
qtscriptbindings-0.1.0-8.fc12.i686
pinentry-qt-0.7.6-4.fc12.i686
qt3-devel-3.3.8b-28.fc12.i686
qt3-designer-3.3.8b-28.fc12.i686
qt3-3.3.8b-28.fc12.i686
ibus-qt-1.2.0.20091014-1.fc12.i686
[qt4@localhost Downloads]$
From the Qt Designer help/about dialog:
About Qt
This program uses Qt version 4.5.3.