Qt-interest Archive, April 2007
QAction and emit
Message 1 in thread
On 23.04.2007 10:39, suleiman wrote:
On 22.04.2007 14:47, suleiman wrote:
Hi i have a slot connected to a QAction toolbarbutton
and it works fine and calls the slot when the button is clicked();
Connect(actionStart, SIGNAL(triggered()), parse, SLOT(startSim()));
this is done in class enhancedGui.
But in class ScenParser if i try to call the slot without the connect
startSim();
it doesnt do behave the same way as it does when the button is connected.
Question is why? what difference does it make its just a signal which
is emited in both ways.
i even tried emit(guiObject->actionStart->trigger()); which also does
the same as startSim(); but doesnt behave the same way as if the
button is clicked. i debuged
and iam entering the function but it is not doing anything in the
simulation.
any help please, thanks in advance.
--
[ signature omitted ]
Message 2 in thread
On 23.04.07 10:47:37, suleiman wrote:
> On 23.04.2007 10:39, suleiman wrote:
>
> On 22.04.2007 14:47, suleiman wrote:
> Hi i have a slot connected to a QAction toolbarbutton
> and it works fine and calls the slot when the button is clicked();
>
> Connect(actionStart, SIGNAL(triggered()), parse, SLOT(startSim()));
>
> this is done in class enhancedGui.
>
> But in class ScenParser if i try to call the slot without the connect
> startSim();
> it doesnt do behave the same way as it does when the button is connected.
> Question is why? what difference does it make its just a signal which
> is emited in both ways.
> i even tried emit(guiObject->actionStart->trigger()); which also does
> the same as startSim(); but doesnt behave the same way as if the button is clicked. i debuged
> and iam entering the function but it is not doing anything in the
> simulation.
> any help please, thanks in advance.
How do you expect us to help you? You didn't show any code, so we can't
even guess whats going wrong.
Andreas
--
[ signature omitted ]
Message 3 in thread
On 23.04.2007 10:57, Andreas Pakulat wrote:
> On 23.04.07 10:47:37, suleiman wrote:
>> On 23.04.2007 10:39, suleiman wrote:
>>
>> On 22.04.2007 14:47, suleiman wrote:
>> Hi i have a slot connected to a QAction toolbarbutton
>> and it works fine and calls the slot when the button is clicked();
>>
>> Connect(actionStart, SIGNAL(triggered()), parse, SLOT(startSim()));
>>
>> this is done in class enhancedGui.
>>
>> But in class ScenParser if i try to call the slot without the connect
>> startSim();
>> it doesnt do behave the same way as it does when the button is connected.
>> Question is why? what difference does it make its just a signal which
>> is emited in both ways.
>> i even tried emit(guiObject->actionStart->trigger()); which also does
>> the same as startSim(); but doesnt behave the same way as if the button is clicked. i debuged
>> and iam entering the function but it is not doing anything in the
>> simulation.
>> any help please, thanks in advance.
>
> How do you expect us to help you? You didn't show any code, so we can't
> even guess whats going wrong.
>
> Andreas
>
Here is the code Andreas sorry.
************Startsim function in Scen_Parser class**********
void Scen_Parser::startSim()
{
//if hideRanges, hideLinks is down, then call hideRanges();
hideLinks();
cout <<"called\n"<<endl;
displayTime = 0.0;
stoped = 0;
guiObject->actionPause->setDisabled(0);
guiObject->actionStop->setDisabled(0);
/* since we have different scenario files ns2 and simplified
we must find out where time stops, either at the end of scenario
file or
in between
*/
double timerLength;
if (time[time.size()-1] > destTime[destTime.size()-1]) {
timerLength = time[time.size()-1];
timeOrDest = true;
}
else {
timerLength = destTime[destTime.size()-1];
timeOrDest = false;
}
guiObject->progressbar->show();
guiObject->progressbar->setFormat( "%m" );
guiObject->progressbar->setRange(0,(int)timerLength);
guiObject->timeLengthLabel->setNum(timerLength);
QString area = QString::number(scenMax_x) + "x" +
QString::number(scenMax_y);
guiObject->areaLabel->setText(area);
sliderValue = 1000;
iPos = 0;
jPos = 0;
timerVal = 0;
timer = new QTimer;
elapsedTime = new QTime;
elapsedTime->start();
timer->start(sliderValue);
connect(timer, SIGNAL(timeout()), this, SLOT( timeincr()));
connect(timer, SIGNAL(timeout()), this, SLOT( showTime()));
connect(guiObject->mySlider, SIGNAL(valueChanged(int)), this,
SLOT(sliderIncr()));
connect(guiObject->actionPause, SIGNAL(triggered()), this,
SLOT(pauseSim()));
connect(guiObject->actionStop, SIGNAL(triggered()), this,
SLOT(stopSim()));
prepare();
}
***********finishAnim function in Scen_Parser class*******
inline void Scen_Parser::finishAnim()
{
cout <<"in finishAnim"<<endl;
foreach(Node *node, mapNodes){
node->moveTimeLine->stop();
}
if (guiObject->loopCheckBox->isChecked() == true){
stopSim();
delete timer;
delete elapsedTime;
foreach(Node *node, mapNodes){
delete node;
}
//tried to delete allocated stuff in the heap, it doesnt help if //its
removed
startSim();
}
}
************th connect stuff in enhancedGui class**********
QObject::connect(actionStart, SIGNAL(triggered()), parse,
SLOT(startSim()));
--
[ signature omitted ]
Message 4 in thread
On 23.04.2007 11:06, suleiman wrote:
> On 23.04.2007 10:57, Andreas Pakulat wrote:
>> On 23.04.07 10:47:37, suleiman wrote:
>>> On 23.04.2007 10:39, suleiman wrote:
>>>
>>> On 22.04.2007 14:47, suleiman wrote:
>>> Hi i have a slot connected to a QAction toolbarbutton
>>> and it works fine and calls the slot when the button is clicked();
>>>
>>> Connect(actionStart, SIGNAL(triggered()), parse, SLOT(startSim()));
>>>
>>> this is done in class enhancedGui.
>>>
>>> But in class ScenParser if i try to call the slot without the connect
>>> startSim();
>>> it doesnt do behave the same way as it does when the button is
>>> connected.
>>> Question is why? what difference does it make its just a signal which
>>> is emited in both ways.
>>> i even tried emit(guiObject->actionStart->trigger()); which also does
>>> the same as startSim(); but doesnt behave the same way as if the
>>> button is clicked. i debuged
>>> and iam entering the function but it is not doing anything in the
>>> simulation.
>>> any help please, thanks in advance.
>>
>> How do you expect us to help you? You didn't show any code, so we can't
>> even guess whats going wrong.
>>
>> Andreas
>>
>
> Here is the code Andreas sorry.
>
>
>
> ************Startsim function in Scen_Parser class**********
>
> void Scen_Parser::startSim()
> {
> //if hideRanges, hideLinks is down, then call hideRanges();
> hideLinks();
> cout <<"called\n"<<endl;
> displayTime = 0.0;
> stoped = 0;
> guiObject->actionPause->setDisabled(0);
> guiObject->actionStop->setDisabled(0);
> /* since we have different scenario files ns2 and simplified
> we must find out where time stops, either at the end of scenario
> file or
> in between
> */
> double timerLength;
> if (time[time.size()-1] > destTime[destTime.size()-1]) {
> timerLength = time[time.size()-1];
> timeOrDest = true;
> }
> else {
> timerLength = destTime[destTime.size()-1];
> timeOrDest = false;
> }
> guiObject->progressbar->show();
> guiObject->progressbar->setFormat( "%m" );
> guiObject->progressbar->setRange(0,(int)timerLength);
> guiObject->timeLengthLabel->setNum(timerLength);
>
> QString area = QString::number(scenMax_x) + "x" +
> QString::number(scenMax_y);
> guiObject->areaLabel->setText(area);
>
> sliderValue = 1000;
> iPos = 0;
> jPos = 0;
> timerVal = 0;
> timer = new QTimer;
> elapsedTime = new QTime;
> elapsedTime->start();
>
> timer->start(sliderValue);
> connect(timer, SIGNAL(timeout()), this, SLOT( timeincr()));
> connect(timer, SIGNAL(timeout()), this, SLOT( showTime()));
> connect(guiObject->mySlider, SIGNAL(valueChanged(int)), this,
> SLOT(sliderIncr()));
> connect(guiObject->actionPause, SIGNAL(triggered()), this,
> SLOT(pauseSim()));
> connect(guiObject->actionStop, SIGNAL(triggered()), this,
> SLOT(stopSim()));
> prepare();
>
>
> }
> ***********finishAnim function in Scen_Parser class*******
>
> inline void Scen_Parser::finishAnim()
> {
> cout <<"in finishAnim"<<endl;
> foreach(Node *node, mapNodes){
> node->moveTimeLine->stop();
> }
> if (guiObject->loopCheckBox->isChecked() == true){
>
> stopSim();
>
> delete timer;
> delete elapsedTime;
> foreach(Node *node, mapNodes){
> delete node;
> }
> //tried to delete allocated stuff in the heap, it doesnt help if
> //its removed
>
> startSim();
> }
> }
>
>
> ************th connect stuff in enhancedGui class**********
>
> QObject::connect(actionStart, SIGNAL(triggered()), parse,
> SLOT(startSim()));
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
Anyone who understand my question, and can give me a clear answer?
because it makes no sense, that a connect(..); should work while calling
the same function the connect is calling is not working.
--
[ signature omitted ]
Message 5 in thread
>
> Anyone who understand my question, and can give me a clear answer?
> because it makes no sense, that a connect(..); should work while
calling
> the same function the connect is calling is not working.
Well... Look into whatg is happening AFTER the call when its called
programmatically.
Your setText calls, and setValue calls require a paintEvent to occur...
If there is no paintEvent, then they will not get updated.
So the question is, if your calling it outside the event look, are you
calling processEvents
--
[ signature omitted ]
Message 6 in thread
Please reply to the group as well
________________________________
From: suleiman [mailto:suleimaj@xxxxxxxxxx]
Sent: Mon 4/23/2007 10:31 AM
To: Scott Aron Bloom
Subject: Re: QAction and emit
Scott Aron Bloom skrev:
>> Anyone who understand my question, and can give me a clear answer?
>> because it makes no sense, that a connect(..); should work while
>>
> calling
>
>> the same function the connect is calling is not working.
>>
>
>
> Well... Look into whatg is happening AFTER the call when its called
> programmatically.
>
> Your setText calls, and setValue calls require a paintEvent to occur...
> If there is no paintEvent, then they will not get updated.
>
> So the question is, if your calling it outside the event look, are you
> calling processEvents
>
I didnt understand this, but it has nothing to do with the setText and
setValue, thoose are just for updating the pos. of the scenario.
But iam having problems calling the function timerinc(); which have the
clock ticks and makes the whole scenario continue.
Iam able to call it outside of this class with the
connect(slot(startSim()); but iam not able to call the slot as a normal
function, if i do that then inside startSim() the function timerinc is
never called..... why?
--
[ signature omitted ]