Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7218613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:30:21+00:00 2026-05-28T21:30:21+00:00

this’s the QTread’s subObject… and concrete it in main Thread…. the Runtime error as

  • 0

this’s the QTread’s subObject…
and concrete it in main Thread….

the Runtime error as follow:

ASSERT failure in QCoreApplication::sendEvent: “Cannot send events to
objects owned by a different thread. Current thread 176f0a8. Receiver
” (of type ‘MainWindow’) was created in thread 3976a0″, file
c:\ndk_buildrepos\qt-desktop\src\corelib\kernel\qcoreapplication.cpp,
line 405 Invalid parameter passed to C runtime function. Invalid
parameter passed to C runtime function.

class PaintThread : public QThread {

private:
    QWidget* parent;

public:
    ~PaintThread() {}

    PaintThread(QWidget* parent = 0) {
        this->parent = parent;
    }

    void run() {
        while (1) {
            this->msleep(5000);
            parent->repaint();
        }
        this->exec();
    }
};

this’s the MainFrame ‘s constructor :

MainWindow::MainWindow(QWidget *parent) :
QWidget(parent)
{
tankPoint = new QRect(50, 50, 30, 30);

this->show();

PaintThread * pt = new PaintThread(this);
pt->start();
}

the follow is the override paintEvent for MainWindow

void paintEvent(QPaintEvent*) {
    QPainter  p(this);

    p.setPen(Qt::red);
    p.setBrush(Qt::red);
    p.drawEllipse(*tankPoint);

    tankPoint->setLeft(200);
}

Can anyone tell me why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T21:30:22+00:00Added an answer on May 28, 2026 at 9:30 pm

    The parent (in this case your MainWindow) lives in a different thread. According to Qt documentation

    You can manually post events to any object in any thread at any time using the thread-safe function QCoreApplication::postEvent(). The events will automatically be dispatched by the event loop of the thread where the object was created.
    Event filters are supported in all threads, with the restriction that the monitoring object must live in the same thread as the monitored object. Similarly, QCoreApplication::sendEvent() (unlike postEvent()) can only be used to dispatch events to objects living in the thread from which the function is called.

    So as a solution I would propose the following:

    • Define a signal in your PaintThread class
    • connect this signal to the paint() slot in QWidget subclass
    • Emit it in the run() function
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This error just started popping up all over our site. Permission denied to call
This is driving me insane! Here's the code: public static void main(String[] strings) {
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This question is in context with the problem mentioned in this thread . I'm
this gives me an error, Bad Reciever type 'NSIntegar (aka 'int'). NSString *tempTag =
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
This is a bit of a long shot, but if anyone can figure it
This is starting to vex me. I recently decided to clear out my FTP,
This is kinda oddball, but I was poking around with the GNU assembler today
This might seem like a stupid question I admit. But I'm in a small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.