generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: No infinite loops?

Previous Thread :: Next Thread 
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
17 Mar 2012 06:11 PM
Hi, I'm working in Qt Creator, specifically in a Qt Widget Project, and coding in C++.

It seems to be that infinite loops cause the widget project to not respond. Examine this pastebin code, which seems to cause the program to become unresponsive:

/7RVWmk9p

(note that most of the lines are commented out)

~Flurite
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
17 Mar 2012 06:19 PM
Yeah, in Qt you shouldn't have infinite loops in events. You can set a timer to run a function every now and then.
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
17 Mar 2012 06:23 PM
like threading?

if so, how?

~Flurite
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
17 Mar 2012 06:26 PM
Create a QTimer object and set its timeout signal to whatever slot you want (I assume you're familiar with slots because it's what Qt uses for its events... if not then I'll try to explain)
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
17 Mar 2012 06:34 PM
Thank you very much. I'm going to look into it and reply back with any questions!
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
17 Mar 2012 06:49 PM
Wow, in the first example om the documentation of QTimer, there are lots of things I don't understand.. like the * operator in front of the declaration of the timer, and the new data type or whatever, the connect() function, and oh dear!

Is there a simpler way to create a QTimer?
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
17 Mar 2012 06:52 PM
Yeah, like:

QTimer timer;

connect(&timer,SIGNAL(timeout),this,SLOT(idkwhatever));


should work fine... I think...
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
17 Mar 2012 06:53 PM
um, whats connect()?
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
17 Mar 2012 06:56 PM
u use it to connect signals to slots...
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
17 Mar 2012 06:59 PM
is that somethin like built into the widget system?
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
17 Mar 2012 07:12 PM
yep
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
18 Mar 2012 08:30 AM
i dun get it >:(

Clock_Application::Clock_Application(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Clock_Application)
{
ui->setupUi(this);
QTimer *timer_Stopwatch = new QTimer(this);
connect(timer_Stopwatch, SIGNAL(timeout()), this, SLOT(timer_Start()));
timer_Stopwatch->start(1000);
}

still not responding
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
18 Mar 2012 08:32 AM
If you need it in a better format: /WcFJeaF1

Also, do you think using QThreads would work better?
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
18 Mar 2012 11:46 AM
Do you have a timer_Start slot in your Clock_Application class? You can make one like:

class Clock_Application {
Q_OBJECT
public slots:
void mySlot(void);
};


void Clock_Application::mySlot(void) {
I->like("pie");
}
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
18 Mar 2012 11:58 AM
Oh I solved my little problem by putting this at the end of my loop:

QCoreApplication::processEvents()
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image