QObject::installEventFilter(): Cannot filter events for objects in a different thread

QObject::installEventFilter(): Cannot filter events for objects in a different thread

Content Index :

QObject::installEventFilter(): Cannot filter events for objects in a different thread
Tag : cpp , By : tangsty
Date : November 28 2020, 01:01 AM

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Error with `QObject` subclass and copy constructor: `QObject::QObject(const QObject&) is private`

Tag : cpp , By : hlpimfalling
Date : March 29 2020, 07:55 AM
it fixes the issue Product is a subclass of QObject, which cannot be copied. Your code is attempting to copy it somewhere (perhaps in productDetails(tempProduct)) and this causes the error. Perhaps you could pass it to your function by const reference instead; or perhaps some redesign of your program is needed.
Your compiler is telling you that the copy constructor of QObject is private, so it cannot be called by any function that is not a method of the base class. Qt has designed it to work that way.

Looping QProgressBar gives error >> QObject::installEventFilter: Cannot filter events for objects in a different t

Tag : development , By : Matt Croydon
Date : March 29 2020, 07:55 AM
I hope this helps . You can't create or access any QWidget outside the main thread.
You can use signals and slots to indirectly access widgets from the other thread:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys, time

class BusyBar(QThread):                     # Looping progress bar
    # create the signal that the thread will emit
    changeValue = pyqtSignal(int)
    def __init__(self, text = "" ):
        self.text = text
        self.stop = False
        self.proBar = QProgressBar()
        self.proBar.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.SplashScreen )
        self.proBar.setRange( 0, 100 )
        self.proBar.setTextVisible( True )
        self.proBar.setFormat( self.text )
        self.proBar.setValue( 0 )
        self.proBar.setFixedSize( 500 , 50 )

        self.changeValue.connect(self.proBar.setValue, Qt.QueuedConnection)
        # Make the Busybar delete itself and the QProgressBar when done        

    def run( self ):
        while not self.stop:                # keep looping while self is visible
            # Loop sending mail 
            for i in range(100):
                # emit the signal instead of calling setValue
                # also we can't read the progress bar value from the thread
                self.changeValue.emit( i )
            self.changeValue.emit( 0 )

    def onFinished(self):

    def Kill(self):
        self.stop = True

class LayoutCreator(QDialog):
    def __init__(self , parent=None):
        super(LayoutCreator, self).__init__(parent)

    def Cameras_Update( self ):                                       
        # Looping progress bar 
        self.busyBar = BusyBar( text = "Gathering Camera Data" )

        # loop through folder structure storing data

        # Simulate async activity that doesn't block the GUI event loop
        # (if you do everything without giving control back to 
        # the event loop, you have to call QApplication.processEvents()
        # to allow the GUI to update itself )
        QTimer.singleShot(10000, self.stopBar)

    def stopBar(self):
        self.busyBar.Kill()                        # Close looping progress bar    

app = QApplication(sys.argv)
win = LayoutCreator()

Updating QTableView raise : QObject::installEventFilter(): Cannot filter events for objects in a different thread

Tag : python , By : dormsbee
Date : March 29 2020, 07:55 AM
may help you . I found a solution, but i don't really understand what was wrong.
In the method : on_document_updated : i commented the lines :
def on_document_updated(self, ns, ts, _id, mod, raw, **kw):
    old_device = None
    updated_device = None
    # self.beginResetModel()
    if len(mod) is 1: # Simple row update from this application (not necessary this instance)
        updated_device = get_mongoengine_model_from_id(_id)
        old_device = [x for x in self.devices if x.mac_adress == updated_device.mac_adress][0]
    else:  # Complete update from the database
        updated_device = get_mongoengine_model_from_pymongo_obj(mod)

        old_device = [x for x in self.devices if x.mac_adress == mod["mac_adress"]][0]
    idx = self.devices.index(old_device)
    self.devices[idx] = updated_device
    # self.endResetModel()

    top_left = self.index(0, 0)
    bottom_right = self.index(self.rowCount() - 1,
                              self.columnCount() - 1)
    self.dataChanged.emit(top_left, bottom_right)

deallocate objects that live in a thread that has just ended, by connecting the finished() signal to QObject::deleteLate

Tag : cpp , By : Kyle
Date : March 29 2020, 07:55 AM
may help you . If a QThread ends (when it run() method returns) it sends the signal QThread::finished. Every QObject whose deleteLater slot is connected to this signal gets deleted.
If you connect the QThread::finished() signal to QObject::deleteLater() method of the worker object as mentioned in the documentation of QThread (http://doc.qt.io/qt-5/qthread.html#details), then the worker is deleted after the QThread has finished. All other QObjects which you have created within the worker will still exist. If you want them to be deleted too you have to either connect them to the same QThread::finished() signal or you use the parent-child-mechanism by setting the worker object as parent of the other object (either by passing it as parent in the constructor (http://doc.qt.io/qt-5/qobject.html#QObject) or by setting it explicitly with void QObject::setParent(QObject *parent) (http://doc.qt.io/qt-5/qobject.html#setParent).

compiler error C2248:'QObject::Qobject':cannot access private member declared in class 'QObject'

Tag : qt , By : Longchao Dong
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Returning the size of available virtual memory at run-time in C++
  • Parallel computing for integrals
  • How do I force my std::map to deallocate memory used?
  • C++ Templates: implicit conversion, no matching function for call to ctor
  • Adding python script to c++ project
  • C++ private pointer "leaking"?
  • Initializing Primitive Array to One Value
  • how is push_back implemented in STL vector?
  • C++ Profiling: KiFastSystemCallRet
  • Multiple rows with a single INSERT in SQLServer 2008
  • Use super class's address/pointer in initialization list
  • double fork using vfork
  • Convert char pointer (char*) to struct
  • Does anyone have good tips for using pc-lint?
  • C++ How fast is passing around objects?
  • template type's ctor arguments at instantiation time
  • Get list of windows in taskbar on Windows 7?
  • Curl connection options
  • Best cross-platform solution for network server?
  • simple c++ file opening issue
  • Switching from C++ (with a lot of STL use) to C for interpreter building
  • How can I access the JPEG image pixels as a 3D array like we do in MATLAB?
  • What wording in the C++ standard allows static_cast<non-void-type*>(malloc(N)); to work?
  • Avoid allocating in constructor or preserve simplicity (and RAII?)
  • Can C++ raise an error when std array initialization is too small?
  • Reference to end is ambiguous
  • Problem with basic usage of std::enable_if
  • How to print out a decimal number as octal number using setiosflags in C++
  • Open Visual Studio with solution and specific file and line
  • Enum value based on template type
  • Is there any way to swap nodes in std::list?
  • How to copy QString into wchar_t buffer
  • Make the compiler generate an empty default function for an std::function
  • Insert or push_back to end of a std::vector?
  • Best practice for const temporary types
  • Include CSV File in Complied Binary
  • Issue with binding non static function to callback
  • How can read from some files and write content of them with different form into files with same names
  • Why does auto deduce this variable as double and not float?
  • no instance of overloaded function "std::make_unique" matches the argument list, but works with unique_ptr con
  • How to see array size from a pointer in c++
  • Error taking address of temporary in Eclipse
  • Using an iterator to go through a vector and modify the contents
  • Are extern extern "C", and extern "C" extern, allowed?
  • Can't solve C2660 and C2065 Errors
  • C referencing C++ extern
  • How to write the definition of a derived class in c++?
  • Why when I include <cmath> I need to use the namespace std too?
  • How to assign a 32-bit unsigned integer to a bit field containing 32 bits
  • Why does the same class being defined in multiple .cpp files not cause a linker multiple definition error?
  • C++ 11db error when trying to quit the program in xcode. beginner level
  • Add content of a vector into a Capnproto map object
  • Recursively Pass Template Template To a Template Template Function
  • Swap rows in a 2D array with std::swap. How does it work?
  • Is there any situation in which an object's storage might change during its lifetime?
  • clang++ always generates empty profraw coverage reports
  • Do memory leaks persist after program completion if the OS does not clear it?
  • How to link library using cmake
  • How to use getters and setters without generating a copy?
  • Generating multiple amounts of the same sprite broken
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com