Qt-interest Archive, April 2007
Why doesnt this Work!
Message 1 in thread
Why does this Work?
connect(qationbutton, SIGNAL(triggered()), parse, SLOT(startSim()));
and Why doesnt this work startSim(); ??
I have posted around 4 emails about this subject, without anyone giving
me a clear idea what the problem might be.
I have posted the code, pseudo kode. And when I say why doesnt this
work, i mean the function is called but it gott timers inside and they
dont call the proper function.
startSim(){
QTimer *time = new QTimer(this);
timer->start(1000);
connect(timer, timeout, this, timeIncr());
now the interesting part is that this connect works perfect if the user
clicks on the button qactionButton (statement above) but if the startSim
slot is called as a function it wont work.
}
--
[ signature omitted ]
Message 2 in thread
Please create a minimal compilable example that illustrates the problem
instead of trying to rewrite the code in your email. There is no way
that the code below is actually what you are using since it wouldn't
even compile; you create a new QTimer called "time" and then try to
start a QTimer called "timer".
The only thing I can think of based on your emails is that wherever you
are that you are calling startSim() explicitly in your code doesn't have
an event loop running, so therefore no signals/slots.
Usually if you post 4 times and don't get a response it means that you
aren't being clear enough in your email to show us what the real problem
is.
Sean
-----Original Message-----
From: suleiman [mailto:suleimaj@xxxxxxxxxx]
Sent: Tuesday, April 24, 2007 10:04 AM
To: qt-interest@xxxxxxxxxxxxx
Subject: Why doesnt this Work!
Why does this Work?
connect(qationbutton, SIGNAL(triggered()), parse, SLOT(startSim()));
and Why doesnt this work startSim(); ??
I have posted around 4 emails about this subject, without anyone giving
me a clear idea what the problem might be.
I have posted the code, pseudo kode. And when I say why doesnt this
work, i mean the function is called but it gott timers inside and they
dont call the proper function.
startSim(){
QTimer *time = new QTimer(this);
timer->start(1000);
connect(timer, timeout, this, timeIncr()); now the interesting part is
that this connect works perfect if the user clicks on the button
qactionButton (statement above) but if the startSim slot is called as a
function it wont work.
}
--
[ signature omitted ]
Message 3 in thread
On 24.04.2007 16:14, Murphy, Sean M. wrote:
> Please create a minimal compilable example that illustrates the problem
> instead of trying to rewrite the code in your email. There is no way
> that the code below is actually what you are using since it wouldn't
> even compile; you create a new QTimer called "time" and then try to
> start a QTimer called "timer".
>
> The only thing I can think of based on your emails is that wherever you
> are that you are calling startSim() explicitly in your code doesn't have
> an event loop running, so therefore no signals/slots.
>
> Usually if you post 4 times and don't get a response it means that you
> aren't being clear enough in your email to show us what the real problem
> is.
>
> Sean
>
> -----Original Message-----
> From: suleiman [mailto:suleimaj@xxxxxxxxxx]
> Sent: Tuesday, April 24, 2007 10:04 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Why doesnt this Work!
>
> Why does this Work?
>
> connect(qationbutton, SIGNAL(triggered()), parse, SLOT(startSim()));
>
> and Why doesnt this work startSim(); ??
>
> I have posted around 4 emails about this subject, without anyone giving
> me a clear idea what the problem might be.
>
> I have posted the code, pseudo kode. And when I say why doesnt this
> work, i mean the function is called but it gott timers inside and they
> dont call the proper function.
>
>
> startSim(){
>
> QTimer *time = new QTimer(this);
> timer->start(1000);
> connect(timer, timeout, this, timeIncr()); now the interesting part is
> that this connect works perfect if the user clicks on the button
> qactionButton (statement above) but if the startSim slot is called as a
> function it wont work.
>
> }
>
> --
> 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/
>
> --
> 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/
>
As i said its pseudo kode, and ofcourse i have pasted yesterday the
whole code, its 450 lines of code in just one of the files iam having
problems with. if i pasted the whole 1200 lines of code it would be too
difficult and none gott time to read trought it, therfor i tried to
minimize where i think the problem might be and. thats why i wrote the
pseudo code.
anyway its QTimer *timer = new QTimer(this); and timer is always used
not time. its just a typo.
but if you would like i can paste the code for that file:
#include "Controll.h"
#include <QImageReader>
#include <QDebug>
#include <QAction>
using namespace std;
Scen_Parser::Scen_Parser(QGraphicsScene *scene)
{
this->scene = scene;
scene->setBackgroundBrush(Qt::lightGray);
sliderValue = 1000;
timerVal = 0;
comRange = 0.0;
brRange = 0.0;
isPause = 0;
stoped = false;
firstSlide = 0;
displayTime = 0.0;
ms = 0;
topomanSock = new QUdpSocket; //udp messages to topologymanager
}
void Scen_Parser::open_scenfile()
{
timer = new QTimer(this);
clearScenario();
guiObject->progressbar->show();
guiObject->actionStart->setDisabled(1);
if (stoped == false)
fileName = QFileDialog::getOpenFileName(0, "Open Scenario File",
"scenario");
QFile file(fileName);
int read = 0;
int size = file.size();
guiObject->QMainWindow::setWindowTitle("NEMAN: " +fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
while (!file.atEnd()) {
QString line = file.readLine();
read += line.length();
QString found;
/* # nodes: 10, pause: 3.00, max speed: 3.00, max x: 1000.00, max y:
1000.00 */
static QRegExp
rx("#\\s+\\w*:\\s+(\\d+),\\s+\\w*:\\s+([-+]?[0-9]\\.?[0-9]+),\\s+\\w*\\s+\\w*:\\s+([-+]?[0-9][0-9]?\\.?[0-9]+),\\s+\\w*\\s+\\w*:\\s+([-+]?[0-9]*\\.?[0-9]+),\\s+\\w*\\s+\\w*:\\s+([-+]?[0-9]*\\.?[0-9]+)");
if (rx.indexIn(line) != -1) {
found = rx.cap(0);
numNodes = rx.cap(1).toInt();
pause = rx.cap(2).toDouble();
max_speed = rx.cap(3).toDouble();
scenMax_x = rx.cap(4).toDouble();
scenMax_y = rx.cap(5).toDouble();
}
static QRegExp
rx_2("#\\s+\\w*:\\s+(\\d+),\\s+\\w*:\\s+([-+]?[0-9]\\.?[0-9]+),\\s+\\w*\\s+\\w*:\\s+([-+]?[0-9][0-9]?\\.?[0-9]+)\\s+\\w*\\s+\\w*\\s+\\=\\s+([-+]?[0-9]*\\.?[0-9]+),\\s+\\w*\\s+\\w*:\\s+([-+]?[0-9]*\\.?[0-9]+)");
if (rx_2.indexIn(line) != -1) {
found = rx_2.cap(0);
numNodes = rx_2.cap(1).toInt();
pause = rx_2.cap(2).toDouble();
max_speed = rx_2.cap(3).toDouble();
scenMax_x = rx_2.cap(4).toDouble();
scenMax_y = rx_2.cap(5).toDouble();
}
/* $node_(0) set X_ 305.182504346120 */
static QRegExp rx2("(\\w*\\((\\d+\\)))\\s+\\w*\\s+\\w*\\s+([-+]?[0-9].*)");
if (rx2.indexIn(line) != -1){
QString name = rx2.cap(1);
QString found2 = rx2.cap(0);
x = rx2.cap(3).toDouble();
if (x > 0.0 )//we are not interested in Z only X, Y.
myVector.push_back(x);
}
/* $god_ set-dist 0 1 16777215 */
static QRegExp rx3("^\\$god_?\\s+\\w*-\\w*\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)");
if(rx3.indexIn(line) != -1){
QString test = rx3.cap(0);
node1.push_back(rx3.cap(1).toInt());
node2.push_back(rx3.cap(2).toInt());
reachAble.push_back(rx3.cap(3).toInt());
}
/*$ns_ at 3.000000000000 "$node_(0) setdest 866.099161363353
753.025172657621 0.751030275648"
*/
static QRegExp
rx4("^\\$\\w*\\s+\\w*\\s+([-+]?[0-9]*\\.?[0-9]+)\\s+\\\"\\$\\w*\\((\\d+)\\)\\s+\\w*\\s+([-+]?[0-9]*\\.?[0-9]+)\\s+([-+]?[0-9]*\\.?[0-9]+)\\s+([-+]?[0-9]*\\.?[0-9]+)");
if (rx4.indexIn(line) != -1){
time.push_back(rx4.cap(1).toDouble());
//cout <<"CAPTURE: "<<rx4.cap(1).toDouble()<<endl;
nodeNr.push_back(rx4.cap(2).toInt());
posX.push_back(rx4.cap(3).toDouble());
posY.push_back(rx4.cap(4).toDouble());
speed.push_back(rx4.cap(5).toDouble());
}
/* $ns_ at 41.329826354576 "$god_ set-dist 2 3 2" */
static QRegExp
rx5("^\\$\\w*\\s+\\w*\\s+([-+]?[0-9]*\\.?[0-9]+)\\s+\\\"\\$\\w*\\s+\\w*\\-\\w*\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)");
if (rx5.indexIn(line) != -1){
destTime.push_back(rx5.cap(1).toDouble());
destNode1.push_back(rx5.cap(2).toInt());
destNode2.push_back(rx5.cap(3).toInt());
destReachable.push_back(rx5.cap(4).toInt());
}
static QRegExp rx6("^\\#\\s+data_range:\\s+([-+]?[0-9]*\\.?[0-9]+)");
if (rx6.indexIn(line) != -1){
comRange = rx6.cap(1).toDouble();
}
static QRegExp rx7("^\\#\\s+broadcast_range:\\s+([-+]?[0-9]*\\.?[0-9]+)");
if (rx7.indexIn(line) != -1){
brRange = rx7.cap(1).toDouble();
}
QApplication::processEvents();//thread the gui, when busy.
guiObject->progressbar->setRange(0,size);
guiObject->progressbar->setValue(read);
}
guiObject->progressbar->hide();
guiObject->actionStart->setDisabled(0);
prepareNodes();
if (guiObject->hideRange->isChecked())
hideOrShowRanges();
if (guiObject->hideLinks->isChecked())
hideOrShowLinks();
if (guiObject->fitInBox->isChecked())
fitIn();
}
void Scen_Parser::clearScenario()
{
/* before we open new scenario we remove previous if any */
if(!mapNodes.isEmpty()){
myVector.clear();
node1.clear();
node2.clear();
reachAble.clear();
posX.clear();
posY.clear();
time.clear();
nodeNr.clear();
speed.clear();
destTime.clear();
destNode1.clear();
destNode2.clear();
QList<QGraphicsItem *> list = scene->items();
QList<QGraphicsItem *>::Iterator it = list.begin();
for (; it != list.end(); ++it) {
if ( *it && (*it)->parentItem() == 0 ){
scene->removeItem(*it);
}
}
QList<Node *> list2;
foreach(Node *node, mapNodes){ list2.append(node); }
QList<Node *>::Iterator it2 = list2.begin();
for (; it2 != list2.end(); ++it2) {
delete *it2;
}
mapNodes.clear();
}
}
/* positions the node in the scene*/
void Scen_Parser::prepareNodes()
{
connect(timer, SIGNAL(timeout()), this, SLOT( timeincr()));
connect(timer, SIGNAL(timeout()), this, SLOT( showTime()));
connect(guiObject->actionPause, SIGNAL(triggered()), this,
SLOT(pauseSim()));
connect(guiObject->actionStop, SIGNAL(triggered()), this,
SLOT(stopSim()));
connect(guiObject->mySlider, SIGNAL(valueChanged(int)), this,
SLOT(sliderIncr()));
scene->setSceneRect(scenMax_x, scenMax_y, 0.0,0.0);
QVector<double> vectorX, vectorY;
for (int i = 0; i < myVector.size(); i+=2)
vectorX.push_back(myVector[i]);
for (int i = 1; i < myVector.size(); i +=2)
vectorY.push_back(myVector[i]);
int nodeNr = guiObject->StartNodeSpinBox->value();
for (int j = 0; j < vectorX.size(); j ++){
Node *node = new Node(this->scene,nodeNr, comRange, brRange,
vectorX[j], vectorY[j]);
mapNodes[j] = node;
nodeNr++;
}
/* physical layer simulation */
connect(guiObject->physicalLayerC, SIGNAL(stateChanged(int)), this,
SLOT(physicalLayerSim()));
connect(guiObject->physicalLayerG, SIGNAL(stateChanged(int)), this,
SLOT(physicalLayerSim()));
connect(guiObject->physicalLayerR, SIGNAL(stateChanged(int)), this,
SLOT(physicalLayerSim()));
connect(guiObject->fitInBox, SIGNAL(stateChanged(int)), this,
SLOT(fitIn()));
}
/* draws the communication and broadcast links between nodes,
done only once in the begining of scenario. */
void Scen_Parser::setReachable()
{
/* set enable first, <startnode numNodes >*/
QString enableData = ENABLE +
QString::number(guiObject->StartNodeSpinBox->value()) + " " +
QString::number(numNodes);
cout <<enableData.toStdString()<<endl;
cout<<"sent: "<<topomanSock->writeDatagram (
enableData.toStdString().c_str(), enableData.length(),
QHostAddress::QHostAddress(guiObject->topomanHostLine->text()),
guiObject->topomanPortLine->text().toInt())<<endl;
for (int i = 0; i < node1.size(); i ++){
int status = reachAble[i];
if (status < 3){
Link key( mapNodes.value(node1[i])->nodeId,
mapNodes.value(node2[i])->nodeId );
QGraphicsLineItem *line =
mapNodes.value(node1[i])->drawComLine(mapNodes.value(node2[i]), status);
links[key] = line;
QString data = LINK + QString::number(node1[i]) + " " +
QString::number(node2[i]) + " " + QString::number(reachAble[i]);
cout <<data.toStdString()<<endl;
cout<<"sent: "<<topomanSock->writeDatagram (
data.toStdString().c_str(), data.length(),
QHostAddress::QHostAddress(guiObject->topomanHostLine->text()),
guiObject->topomanPortLine->text().toInt())<<endl;
}
}
}
/* fix this later.....*/
void Scen_Parser::prepare()
{
setReachable();
}
/* SLOT */
/* this function is called when certain time values is reached
And creates/deletes links between nodes
*/
void Scen_Parser::manageLinks()
{
/* check scenario file if it is ns2, then dont check for broadcast */
QString data = "link " + QString::number(destNode1[jPos]) + " " +
QString::number(destNode2[jPos]) + " " +
QString::number(destReachable[jPos]);
cout <<data.toStdString()<<endl;
cout <<"sent: "<<topomanSock->writeDatagram (
data.toStdString().c_str(), data.length(),
QHostAddress::QHostAddress(guiObject->topomanHostLine->text()),
guiObject->topomanPortLine->text().toInt())<<endl;
int status = destReachable[jPos];
Link key(mapNodes[destNode1[jPos]]->nodeId,
mapNodes[destNode2[jPos]]->nodeId );
QGraphicsLineItem *line =
mapNodes[destNode1[jPos]]->drawComLine(mapNodes.value(destNode2[jPos]),status);
if (status > 2){
mapNodes[destNode1[jPos]]->neighbourList.removeAll(mapNodes[destNode2[jPos]]);
mapNodes[destNode1[jPos]]->com_line_list.removeAll(links[key]);
delete links[key];
links.remove(key);
}
if (status < 3 ){
if (links.contains(key)){
if (mapNodes[destNode1[jPos]]->neighbour->nodeId ==
mapNodes[destNode2[jPos]]->nodeId){
if(!destNode1.isEmpty() &&
!mapNodes[destNode1[jPos]]->com_line_list.isEmpty())
mapNodes[destNode1[jPos]]->com_line_list.removeAll(links[key]);
//removeAll removes all occurrence of (value)
delete links[key];
links.remove(key);
links[key] = line;
}
}
else
links[key] = line;
}
jPos++;
}
void Scen_Parser::startSim()
{
if (!mapNodes.isEmpty())
cout <<"mapNodes is not empty"<<endl;
//if hideRanges, hideLinks is down, then call hideRanges();
hideLinks();
cout <<"called\n"<<endl;
displayTime = 0.0;
stoped = false;
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->start(sliderValue);
prepare();
qDebug()<<"end of functin";
}
void Scen_Parser::timeincr()
{
cout <<"timincr called"<<endl;
guiObject->progressbar->setValue(timerVal);
cout <<"time "<<time[timerVal]<<endl;
while ( !time.isEmpty() && (int)time.first() == timerVal ) {
moveCurrent();
time.pop_front();
}
while ( !destTime.isEmpty() && (int)destTime.first() == timerVal ) {
manageLinks();
destTime.pop_front();
}
QApplication::processEvents();
if( time.isEmpty() && timeOrDest == true )
{
finishAnim();
timer->stop();
}
if( destTime.isEmpty() && timeOrDest == false )
{
finishAnim();
timer->stop();
}
timerVal++;
}
void Scen_Parser::showTime()
{
guiObject->timeLabel->setText(QString::number(displayTime)+"."+QString::number((ms
%1000*1000)/10000));
QApplication::processEvents();
displayTime +=1;
ms+=100;
// foreach(Node *node, mapNodes){
// node->updateComlinks();
// }
}
void Scen_Parser::sliderIncr()
{
double speeds[11] = {0.01, 0.05, 0.1, 0.2, 0.5, 1, 2, 3, 4, 5, 10};
sliderValue = (int) 1000 / speeds[guiObject->mySlider->value()-1];
guiObject->speedNow->setNum(speeds[guiObject->mySlider->value()-1]);
foreach (Node *node, mapNodes ) {
node->timeIncr = sliderValue;
node->moveNodesRestart();
}
timer->setInterval(sliderValue);
}
void Scen_Parser::pauseSim()
{
if (isPause == 0){
foreach (Node *node, mapNodes ) {
node->timeIncr = (int) 1000/0.01;
node->moveNodesRestart();
}
timer->stop();
isPause = 1;
}
else if (isPause == 1){
foreach (Node *node, mapNodes ) {
node->timeIncr = (int) 1000/1;
node->moveNodesRestart();
}
timer->start();
isPause = 0;
}
}
void Scen_Parser::stopSim()
{
cout <<"Stop called"<<endl;
stoped = true;
timer->stop();
disconnect(timer, SIGNAL(timeout()), this, SLOT(timeincr()));
delete timer;
open_scenfile();
}
void Scen_Parser::physicalLayerSim()
{
QString physData = SIMPHY +
QString::number(guiObject->physicalLayerC->isChecked()) +" "+
QString::number(guiObject->physicalLayerG->isChecked()) + " "
+QString::number(guiObject->physicalLayerR->isChecked());
cout <<physData.toStdString()<<endl;
cout <<"sent: "<<topomanSock->writeDatagram (
physData.toStdString().c_str(), physData.length(),
QHostAddress::QHostAddress(guiObject->topomanHostLine->text()),
guiObject->topomanPortLine->text().toInt())<<endl;
}
void Scen_Parser::hideOrShowRanges()
{
if (guiObject->hideRange->isChecked() == true){
foreach (Node *node, mapNodes){
node->undrawRange();
}
}
if (guiObject->hideRange->isChecked() == false){
foreach (Node *node, mapNodes){
node->drawRange();
}
}
}
void Scen_Parser::hideOrShowLinks()
{
if (guiObject->hideLinks->isChecked() == true){
foreach (Node *node, mapNodes){
node->hideLinks();
}
}
if (guiObject->hideLinks->isChecked() == false){
foreach (Node *node, mapNodes){
node->showLinks();
}
}
}
void Scen_Parser::fitIn()
{
if (guiObject->fitInBox->isChecked() == true)
guiObject->myGraphicsview->fitInView(QRectF(0.0,0.0,scenMax_x,scenMax_y),Qt::KeepAspectRatio
);
if (guiObject->fitInBox->isChecked() == false)
guiObject->myGraphicsview->resetMatrix();
}
inline void Scen_Parser::moveCurrent()
{
mapNodes[nodeNr[iPos]]->moveNodes(posX[iPos], posY[iPos],
speed[iPos]);
iPos++;
}
inline void Scen_Parser::finishAnim()
{
foreach(Node *node, mapNodes){
node->moveTimeLine->stop();
}
if (guiObject->loopCheckBox->isChecked() == true){
stopSim();
startSim();
}
}
--
[ signature omitted ]
Message 4 in thread
> >
> As i said its pseudo kode, and ofcourse i have pasted yesterday the
> whole code, its 450 lines of code in just one of the files iam having
> problems with. if i pasted the whole 1200 lines of code it would be
too
> difficult and none gott time to read trought it, therfor i tried to
> minimize where i think the problem might be and. thats why i wrote the
> pseudo code.
>
> anyway its QTimer *timer = new QTimer(this); and timer is always used
> not time. its just a typo.
>
> but if you would like i can paste the code for that file:
I don't think your getting it.
First, none of us get paid to do you work... We don't mind helping, but
going through 450 lines of code, looking for 1 problem line... isn't
easy...
Looking at the example, since your talking about 1 method that's
broke...
YOU (as in not US) could probably reduce it into 20-30 lines of
compliable code.
Maybe even a project file, with what ever options you using...
Another thing, Im going to throw out... your attitude sucks... Ill say
it. No one owes you a solution. People are putting an effort in here,
and your response is that of a child who isn't getting the candy they
wanted.
Now as said before, I bet the problem is in either the event loop not
running (stated yesterday and again today) or you are connecting to the
timeout of the timer AFTER its already passed that time...
Another thing I notice, you should ONLY connect to the timer once... In
your "full" code exaple your connecting it EVERY time your start it.
Scott
--
[ signature omitted ]
Message 5 in thread
On 24.04.2007 16:47, Scott Aron Bloom wrote:
>> As i said its pseudo kode, and ofcourse i have pasted yesterday the
>> whole code, its 450 lines of code in just one of the files iam having
>> problems with. if i pasted the whole 1200 lines of code it would be
> too
>> difficult and none gott time to read trought it, therfor i tried to
>> minimize where i think the problem might be and. thats why i wrote the
>> pseudo code.
>>
>> anyway its QTimer *timer = new QTimer(this); and timer is always used
>> not time. its just a typo.
>>
>> but if you would like i can paste the code for that file:
>
> I don't think your getting it.
>
> First, none of us get paid to do you work... We don't mind helping, but
> going through 450 lines of code, looking for 1 problem line... isn't
> easy...
>
> Looking at the example, since your talking about 1 method that's
> broke...
>
> YOU (as in not US) could probably reduce it into 20-30 lines of
> compliable code.
>
> Maybe even a project file, with what ever options you using...
>
> Another thing, Im going to throw out... your attitude sucks... Ill say
> it. No one owes you a solution. People are putting an effort in here,
> and your response is that of a child who isn't getting the candy they
> wanted.
>
> Now as said before, I bet the problem is in either the event loop not
> running (stated yesterday and again today) or you are connecting to the
> timeout of the timer AFTER its already passed that time...
>
> Another thing I notice, you should ONLY connect to the timer once... In
> your "full" code exaple your connecting it EVERY time your start it.
>
> Scott
>
> --
> 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/
>
Iam really sorry if I wrote like a child, Iam just frustrated because I
really could not understand where the problem could be and i debuged in
hundred different ways.
So again Iam sorry if I said something offending i know you people do a
great job offering your time to help us.
--
[ signature omitted ]
Message 6 in thread
On 24.04.2007 16:14, Murphy, Sean M. wrote:
>> Please create a minimal compilable example that illustrates the
>> problem instead of trying to rewrite the code in your email.
Text snipped...
> As i said its pseudo kode, and ofcourse i have pasted
> yesterday the whole code, its 450 lines of code in just one
> of the files iam having problems with. if i pasted the whole
> 1200 lines of code it would be too difficult and none gott
> time to read trought it, therfor i tried to minimize where i
> think the problem might be and. thats why i wrote the pseudo code.
>
> anyway its QTimer *timer = new QTimer(this); and timer is
> always used not time. its just a typo.
>
> but if you would like i can paste the code for that file:
Posting the whole file is hardly what I mean by posting a "minimal
compilable example". As another email just pointed out, we are all
developers working on our own stuff and don't have time to run through
450 lines of *YOUR* code to find out what you're doing wrong. So forget
your project for now. Write a brand new application that just attempts
to do what you think you are seeing that is wrong. If you can get your
small application to fail, and you still don't understand why it's
failing, send that to the list. But often times the mere exercise of
writing that sample code will illustrate what you are doing wrong and
you will find the bug yourself. Some of us might have time to look over
20-30 lines of code and point out flaws we see, but we don't have time
to run through 450 lines of code, just to find the one line of code that
is causing the problem.
Sean
--
[ signature omitted ]
Message 7 in thread
suleiman schrieb:
> ...
> but if you would like i can paste the code for that file:
No, we don't like this - this is a mailing list for *questions*, not for
debugging other people's code.
Cheers, Oliver
--
[ signature omitted ]
Message 8 in thread
Hi,
suleiman wrote:
> Why does this Work?
>
> connect(qationbutton, SIGNAL(triggered()), parse, SLOT(startSim()));
>
> and Why doesnt this work startSim(); ??
>
> startSim(){
>
> QTimer *time = new QTimer(this);
> timer->start(1000);
> connect(timer, timeout, this, timeIncr());
Because the connect statement in startSim() should read (I guess):
connect( timer, SIGNAL( timeout() ), this, SLOT( timeIncr() ) );
I'm assuming that timeIncr is declared as a slot, etc.
Tim
--
[ signature omitted ]
Message 9 in thread
Try creating an absolutely minimal code example... And explaing what
doesn't work clearly... Also, explain what YOU have done to debug and
diagnose.
Ie, I watch the debugger step into startSim as a method call, however,
the timer does not change its timer value.
Scott
> -----Original Message-----
> From: suleiman [mailto:suleimaj@xxxxxxxxxx]
> Sent: Tuesday, April 24, 2007 7:04 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Why doesnt this Work!
>
> Why does this Work?
>
> connect(qationbutton, SIGNAL(triggered()), parse, SLOT(startSim()));
>
> and Why doesnt this work startSim(); ??
>
> I have posted around 4 emails about this subject, without anyone
giving
> me a clear idea what the problem might be.
>
> I have posted the code, pseudo kode. And when I say why doesnt this
> work, i mean the function is called but it gott timers inside and they
> dont call the proper function.
>
>
> startSim(){
>
> QTimer *time = new QTimer(this);
> timer->start(1000);
> connect(timer, timeout, this, timeIncr());
> now the interesting part is that this connect works perfect if the
user
> clicks on the button qactionButton (statement above) but if the
startSim
> slot is called as a function it wont work.
>
> }
>
> --
> 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/
--
[ signature omitted ]
Message 10 in thread
suleiman schrieb:
> I have posted around 4 emails about this subject, without anyone giving me a clear idea what the problem might be.
As the others already stated, you weren't verbose and concise enough in
your question; this includes the subject you chose. However,
> startSim(){
>
> QTimer *time = new QTimer(this);
> timer->start(1000);
> connect(timer, timeout, this, timeIncr());
if you do it exactly this way, I'm just guessing that it doesn't work
because you don't connect the timeout *before* you start the timer...
Martin
--
[ signature omitted ]
Message 11 in thread
On 24.04.2007 16:27, Martin Gebert wrote:
> suleiman schrieb:
>> I have posted around 4 emails about this subject, without anyone
>> giving me a clear idea what the problem might be.
>
> As the others already stated, you weren't verbose and concise enough in
> your question; this includes the subject you chose. However,
>
>> startSim(){
>>
>> QTimer *time = new QTimer(this);
>> timer->start(1000);
>> connect(timer, timeout, this, timeIncr());
>
> if you do it exactly this way, I'm just guessing that it doesn't work
> because you don't connect the timeout *before* you start the timer...
>
> Martin
>
What do you mean? i dont connect the timeout, please explain in detail
--
[ signature omitted ]
Message 12 in thread
He means that these 2 lines should be switched:
>>> timer->start(1000);
>>> connect(timer, timeout, this, timeIncr());
Should be:
connect(timer, SIGNAL(timeout()), this, SLOT(timeIncr()));
timer->start(1000);
Which makes perfect sense to me.
On 04-24-2007 9:31 AM, "suleiman" wrote:
> On 24.04.2007 16:27, Martin Gebert wrote:
>> suleiman schrieb:
>>> I have posted around 4 emails about this subject, without anyone
>>> giving me a clear idea what the problem might be.
>>
>> As the others already stated, you weren't verbose and concise enough in
>> your question; this includes the subject you chose. However,
>>
>>> startSim(){
>>>
>>> QTimer *time = new QTimer(this);
>>> timer->start(1000);
>>> connect(timer, timeout, this, timeIncr());
>>
>> if you do it exactly this way, I'm just guessing that it doesn't work
>> because you don't connect the timeout *before* you start the timer...
>>
>> Martin
>>
>
>
> What do you mean? i dont connect the timeout, please explain in detail
--
[ signature omitted ]