LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-27-2011, 01:32 AM   #1
divya s
Member
 
Registered: Mar 2011
Posts: 40

Rep: Reputation: 0
which is better to use in qt custom events or threads ?


hi,
I want to know the difference between custom events and threads and i want to write a simple example for custom events. I am new to Qt so i need help.

thank you
 
Old 06-27-2011, 08:28 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Most of the time, you want to treat a system like Qt as "an event-driven system." The main loop of the program processes a queue of events ... very quickly, but one-at-a-time. The design of the system is such that you can define your own, "custom," events, and have them be dispatched just like those which are built-in to Qt.

Threads, in such a context, are usually more trouble than they're worth because the concept really doesn't fit well within the model established by Qt. In fact, it rather defeats the purpose. Threads, when inappropriately used, often spend inordinate amounts of time fooling around with semaphores and other mutual-exclusion objects, whereas "modern CPUs are so damn fast that" a clean, well-implemented, event design can accomplish the same work (often) even faster.

You need to be aware of how both mechanisms work, of course. But most of all, spend serious time in the Qt documentation "really getting to know how it works." In other words, "what were the designers thinking when they wrote this thing, and why?" As they say, "figure out what the Romans are doing."
 
Old 06-27-2011, 10:14 AM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,226

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by divya s View Post
I want to know the difference between custom events and threads
They have nothing in common.

Documentation for both are on doc.qt.nokia.com.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
use of events to communicate between threads in QT navderm Programming 1 01-09-2009 08:48 PM
Keyboard events interrupting mouse events. miner49er Linux - Hardware 3 11-04-2008 04:16 AM
Hang on triggering udev events- is there a buildup of events? sonichedgehog Slackware 20 07-11-2008 02:49 AM
events and threads arunachalam Linux - Networking 3 05-27-2007 12:27 PM
Xlib custom events phanna Programming 1 09-12-2005 04:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration