qt designer에서 pthread 사용 문제..

cdcmp의 이미지

안녕하세요...

pthread에 대해서 문의 할 사항이 있는데요..

혹시 qt designer에서 pthread사용할수 있는가요??

새로운 thread를 불러오는데 포인터 에러가 계속 나는 거 같은데...

혹시 사용해 보신분 있는가요??

감사합니다..

cbycby의 이미지

제가 지금 그렇게 작업하고 있기 때문에 자신있게 말할 수 있습니다.

물론, QT를 사용하면 QThread를 사용하는게 가장 궁합에 잘 맞겠죠...

하지만, QThread를 사용한다고 해서 QT에서 에러를 내거나 하지 않습니다.

자세하게 어떠한 코드를 작성했을때, 어떤 식으로 에러난다는지의

내용을 적어주시면 고맙겠습니다.

아울러 한국 QT 커뮤니티 사이트도 방문해 주셔요~ :-)

http://www.korone.net QT 커뮤니티 사이트

익명 사용자의 이미지

답변 감사합니다..

코드는 beginning linux programming을 참고 했습니다..

#include <pthread.h>
#include <semaphore.h>
.............
.............

.............

void laser::start()
{
   res = sem_init(&bin_sem,0,0);
   
   .............

   res = pthread_create(&a_thread,NULL,thread_function,NULL);
  
   .............

   res = pthread_join(a_thread,&thread_result);

   .............

   sem_destory(&bin_sem);
   exit(EXIT_SUCCESS);
}

void laser::thread_function(void *arg)
{
   .............
}

대략 기본적인 코드는 위와 같습니다..

그러나 여기서 책에서는

void *thread_function(void *arg)
{
   .............
}

이 거와 같이 새로운 쓰레드 함수를 생성 하게 되는데...

qt designer에서는 *thread_fucntion(void *arg) 이러한
포인터 함수를 제공하지 않더라고요...

아직 qt초보라서 어떻게 해야 할지 막막하네요...

답변 부탁드리겠습니다...

cbycby의 이미지

제목 그대로 그냥 쓰셔도 됩니다.

qt 디자이너와 무관한 사항입니다. 직접 소스에 해당 함수를 넣어주시면 됩니다.

근데, qt를 사용하시면서 c 코드를 넣는건 별로 좋지 못한 생각 같습니다.

qt 코드가 c++로 되어 있고, 또한 이렇게 하시면 qt UI message dispatcher를 block 시킵니다.

qt thread를 사용하시길 권장합니다.

http://www.korone.net QT 커뮤니티 사이트

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.