Search
 
SCRIPT & CODE EXAMPLE
 

CPP

qt/c++ exception handler

class BadCounter {
Q_OBJECT
public slots:
  void count() { throw CounterError("unable to count"); }
};

class CounterAdaptor {
Q_OBJECT
  BadCounter* counter_;
public:
  CounterAdaptor(BadCounter* counter) {
    counter_ = counter;
  }
public slots:
  void count() {
    try {
      counter_->count();
    } catch (const CounterError& e) {
      std::cerr << e.what() << std::endl;
    }
  }
};

int main() {
  BadCounter engine;
  CounterAdaptor adaptor(&engine);
  QThread* thread = new QThread();
  connect(thread,SIGNAL(started()),&adaptor,SLOT(count())); 
  thread.start();
  ... // etc...
  delete thread;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: skip headers while reading text 
Cpp :: 1603. Design Parking System leetcode solution in c++ 
Cpp :: polymorphism c++ virtual 
Cpp :: how can I convert each and every element of string push into set in c++? 
Cpp :: object as a function argument and returning object 
Cpp :: const char * to std::wstring 
Cpp :: std::string(size_t , char ) constructor: 
Cpp :: c++ how to print out 
Cpp :: are maps sorted c++ 
Cpp :: reference variablesr in c++ 
Cpp :: In every C++ program: 
Cpp :: powers of 2 in cpp 
Cpp :: c++ install 
Cpp :: strip whitespace c++ 
Cpp :: constants in cpp 
Cpp :: longest increasing subsequence nlogn c++ 
Cpp :: math in section latex 
Cpp :: run with cpp version 
Cpp :: sinonimo de tratar 
C :: remix icon cdn 
C :: purge nvidia 
C :: Donut-shaped C code 
C :: sum of list in C 
C :: how to get user input in c 
C :: successeur d’un entier donné 
C :: c concatenate strings 
C :: nested switch case in c 
C :: addition in c 
C :: install gnome tweaks ubuntu 20.04 
C :: c print to stderr 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =