⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Wt
All Projects
Wt
Overview
Activity
Roadmap
Issues
Wiki
Forums
Download (1.02 KB)
RE: Can new created thread emit signals to Wt thread usin...
» GUIApplication.cpp
ruliang ge
, 05/07/2010 06:46 AM
#include
"GUIApplication.h"
#include
"DataSource.h"
#include
<stdio.h>
#include
<boost/thread.hpp>
#include
<boost/lexical_cast.hpp>
GUIApplication
::
GUIApplication
(
const
WEnvironment
&
env
)
:
WApplication
(
env
),
app_
(
WApplication
::
instance
())
{
setTitle
(
"GUI"
);
counterTest_
=
new
WText
(
"GUI Test"
,
root
());
eventConnection_
=
DataSource
::
getInstance
()
->
sourceEvent
().
connect
(
SLOT
(
this
,
GUIApplication
::
showCounter
));
}
/*
* Signal process function.
* Using Server Push.
*/
void
GUIApplication
::
showCounter
(
int
arg_number
){
WApplication
::
UpdateLock
lock
=
app_
->
getUpdateLock
();
app_
->
attachThread
();
char
number
[
4
]
=
{
0
};
sprintf
(
number
,
"%d"
,
arg_number
);
counterTest_
->
setText
(
""
);
counterTest_
->
setText
(
number
);
app_
->
triggerUpdate
();
}
WApplication
*
createApplication
(
const
WEnvironment
&
env
)
{
return
new
GUIApplication
(
env
);
}
int
main
(
int
argc
,
char
**
argv
)
{
boost
::
thread
(
boost
::
bind
(
&
DataSource
::
Start
,
DataSource
::
getInstance
()));
return
WRun
(
argc
,
argv
,
&
createApplication
);
}
« Previous
1
2
3
4
Next »
(2-2/4)
Loading...