qt GUI이벤트 처리문의

kisungcho의 이미지

qt embedded를 ARM용으로 4.1.4를 사용하고 있습니다.
사용중에 가장 단순한 형태로 만들어서 해보고 있는데 지속적으로 CPU가 상승해서 결국은 90%를 넘깁니다.
qt 내부의 event처리 루틴에서 시간이 올래걸리고 있습니다.
상황은 가장 상위에 screenwidget이 있어서 background의 화면 드로잉을 담당하고요.
timewidget는 screenwidget의 자식클래스로 현재시간을 1초에 한번씩 그려주고 있습니다.
그리고 msghandler는 QOBject로 이벤트를 받아서 상위에서 SkinDialog나 LogOut다이얼로그등 다이얼로그를 실행시키고 이벤트를 처리해주는 역학을 합니다.
헌데 임의의 키가 발생했을때 screenWidget로 이베트를 보내서 후면부 드로잉을 하게 하고 다시 postEvent로 msghandler로 이벤트가 날아와서 SkinDialog를 modal로 띄우면 CPU가 지속적으로 상승하고 있습니다.
x86용 qt에서는 현상이 잘 보이지 않는데 qt embedded에서는 30분만 지켜봐도 CPU가 상승하고 있다는 것을 알수 있습니다. 해서 postEvent대신 signal , slot로 해봐도 마찬가지고요. 지속적으로 drawing 이벤트가 발생하고 있는 child widget을 가지고 있는 widget에 이벤트를 보내고 이곳에서 다시 이벤트를 보내도록 해서 modal로 다이얼로그를 띄우면 항상 발생합니다.
파일은 첨부했구요. 고수님분들의 조언 부탁드립니다.

ScreenWidget -> main background image drawing widget
TimeWidget -> current time display widget per one second(for stress call 0.3 sec)
MsgHandler -> main message handler , this class call modal dialog
SkinDialog -> model dialog
PannelThread -> key event emulat

int main(int argc, char* argv[])
{
	QApplication app( argc, argv );
	ScreenWidget mainwin( NULL );
	g_pScreen = &mainwin;
	mainwin.show();
	g_pMsgHandler = new MsgHandler(&mainwin);
	PannelThreadCreate();

	/*
	SkinDialog *pSkinDlg = new SkinDialog(&mainwin);
	pSkinDlg->exec();
	*/
	app.exec();
}

############################################
void* PannelThread(void* arg)
{
	int cnt = 0;

	while(1){
		sleep(1);
		cnt++;
		printf("pannelthread\n");
		if(cnt == 10){
			QEvent *pEvent = new QEvent( (QEvent::Type)5001);
			QApplication::postEvent(g_pScreen, pEvent);
			break;
		}

	}
}

############################################
void ScreenWidget::customEvent(QEvent *pEvent)
{
	QEvent *pEv = new QEvent( (QEvent::Type)5001);
	QApplication::postEvent(g_pMsgHandler, pEv);
}



############################################
void MsgHandler::customEvent(QEvent *pEvent)
{
	OnSetupMenu();
}


void MsgHandler::OnSetupMenu()
{
	SkinDialog *pSkinDlg = new SkinDialog(NULL);
	pSkinDlg->exec();
}


############################################

CTimeWidget::CTimeWidget( QWidget* parent, Qt::WFlags f  )
: QWidget( parent, f | Qt::FramelessWindowHint)
{

	QFont font = QApplication::font();
	font.setPixelSize( 20 );
	font.setBold( true );
	setFont( font );

	setFixedSize( QSize( SIZE_OF_WIDTH, SIZE_OF_HEIGHT ) );
	setAttribute( Qt::WA_OpaquePaintEvent );

	QSize sizeParent = parent->size();
	QSize sizeThis = size();
	QSize size = sizeParent- sizeThis;
	size /= 2;

	QRect rect = parent->rect();
	move( size.rwidth(), rect.top() + 30 );

	QTimer *pTimer = new QTimer(this);
	connect(pTimer, SIGNAL(timeout()), this, SLOT(update()) ); 
	pTimer->start(300);
	//m_nEveryID = startTimer( 1000 );
	m_CurrentTime = QDateTime::currentDateTime();

}
void CTimeWidget::paintEvent(QPaintEvent *pEvent)	
{
//qDebug("[%s:%s]\n", __FILE__, __func__);
	QPainter paint( this );
	QString strTemp;
	QDateTime dateTime;

	QRect rect = pEvent->rect();

	paint.fillRect( rect, QBrush( QColor( 0, 0, 0 ) ) );
	//paint.fillRect( rect, QBrush( QColor( 255, 255, 255 ) ) );
	m_CurrentTime = QDateTime::currentDateTime();	
	dateTime = m_CurrentTime;
	strTemp = dateTime.toString() ;

	DrawTextOutline( paint, strTemp, rect, Qt::AlignLeft | Qt::AlignVCenter );
}

File attachments: 
첨부파일 크기
Package icon gui_test.zip19.64 KB

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.