[Qt-interest] (no subject)
Neeraj Jhawar
navderm at gmail.com
Fri Jan 9 18:48:28 CET 2009
I am sorry but i did not get what you mean... I am using QT3 ... how do I
"turn off QT3 support".
Please explain. I have spent more than 3 hours stuck with this problem..
On Sat, Jan 10, 2009 at 2:42 AM, Scott Aron Bloom
<Scott.Bloom at sabgroup.com>wrote:
> First, this is new code, turn off QT3 support.
>
> That said, your code worked fine for me. Compiled, linked (I had to
> create a simple main) and it ran fine.
>
> Scott
> > -----Original Message-----
> > From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> > bounces at trolltech.com] On Behalf Of Neeraj Jhawar
> > Sent: Friday, January 09, 2009 9:03 AM
> > To: Qt-interest at trolltech.com
> > Subject: [Qt-interest] (no subject)
> >
> > The code:
> >
> > this program tries to accomplish nothing but to make the signal and
> > slot in different threads work:
> >
> > this part of code is from file threadstuff.cpp
> >
> > #include <qlayout.h>
> > #include <qpushbutton.h>
> >
> > #include <stdlib.h>
> > #include <stdio.h>
> > #include <iostream.h>
> >
> > #include "threadstuff.h"
> >
> > Thread::Thread()
> > {
> > stopped = false;
> > }
> >
> > void Thread::run()
> > {
> > static int aha = 0;
> > while(!stopped)
> > {
> > cerr << messageStr.ascii();
> > if (aha >=100)
> > {
> > emit wow();
> > aha = 0;
> > }
> > aha++;
> > }
> > stopped = false;
> > cerr << endl;
> > }
> >
> > void Thread::stop()
> > {
> > stopped = true;
> > }
> >
> > void Thread::setMessage(const QString &message)
> > {
> > messageStr = message;
> > }
> >
> > void Thread::startOrStopThreadAinthread()
> > {
> > }
> >
> >
> //======================================================================
> =
> >
> > ThreadForm::ThreadForm (QWidget *parent, const char *name) :
> > QDialog(parent, name)
> > {
> > setCaption(tr("Threads"));
> >
> > threadA.setMessage("A");
> >
> > threadAButton = new QPushButton("Start A", this);
> > quitButton = new QPushButton ("Quit", this);
> > quitButton->setDefault(true);
> >
> > connect(threadAButton, SIGNAL(clicked()), this,
> > SLOT(startOrStopThreadA()));
> > connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
> >
> > connect(&threadA, SIGNAL(wow()), this,
> > SLOT(startOrStopThreadAII()));
> > //connect(threadA, SIGNAL(wow()), this,
> > SLOT(startOrStopThreadAII()));
> >
> > QHBoxLayout *layout = new QHBoxLayout(this);
> > layout->addWidget(threadAButton);
> > layout->addWidget(quitButton);
> > }
> >
> >
> >
> > void ThreadForm :: startOrStopThreadA()
> > {
> > if (threadA.running())
> > {
> > threadA.stop();
> > threadAButton->setText(tr("Start A"));
> > }
> > else
> > {
> > threadA.start();
> > threadAButton->setText(tr("Stop A"));
> > }
> > }
> >
> >
> > void ThreadForm :: startOrStopThreadAII()
> > {
> > static int ahaII = 0;
> > if (ahaII == 0)
> > {
> > ahaII++;
> > quitButton->setEnabled(true);
> > }
> > else if (ahaII == 1)
> > {
> > ahaII = 0;
> > quitButton->setEnabled(false);
> > }
> > }
> >
> >
> > void ThreadForm::closeEvent (QCloseEvent *event)
> > {
> > threadA.stop();
> > threadA.wait();
> > event->accept();
> > }
> >
> >
> > =====================================
> >
> > this part of the code is from threadstuff.h
> >
> >
> > #ifndef THREADSTUFF_H
> > #define THREADSTUFF_H
> >
> > #include <qdialog.h>
> > #include <qthread.h>
> >
> > class Thread : public QThread
> > {
> > public:
> > Thread();
> >
> > void startOrStopThreadAinthread();
> > void setMessage(const QString &message);
> > void stop();
> >
> > signals:
> > void wow();
> >
> > protected:
> > void run();
> >
> > private:
> > QString messageStr;
> > volatile bool stopped;
> > };
> >
> >
> > class ThreadForm : public QDialog
> > {
> > Q_OBJECT
> > public:
> > ThreadForm (QWidget *parent = 0, const char *name = 0);
> >
> > protected:
> > void closeEvent(QCloseEvent *event);
> > private slots:
> > void startOrStopThreadA();
> > void startOrStopThreadAII();
> > private:
> > Thread threadA;
> > QPushButton *threadAButton;
> > QPushButton *quitButton;
> > };
> >
> > #endif
> >
> >
> >
> > Thank you
> >
> >
> >
> > --
> > Neeraj Jhawar
> > Senior Undergraduate
> > Mechanical Engineering Department
> > Punjab Engineering College
> > Chandigarh.
> > India
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
Neeraj Jhawar
Senior Undergraduate
Mechanical Engineering Department
Punjab Engineering College
Chandigarh.
India
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090110/b2c8a710/attachment.html
More information about the Qt-interest-old
mailing list