[JavaSE Column 57] Magically use this and super keywords to make the parent class and subclass go back and forth freely

Author Homepage: Designer Xiaozheng About the author: 3 years of JAVA full-stack development experience, focusing on JAVA technology, system customization, remote guidance, dedicated to enterprise digital transformation, certified lecturer of CSDN College and Blue Bridge Cloud Course. Main direction: Vue, SpringBoot, WeChat applet This article explains the syntax and application scenarios of this and super […]

Subclassing QThread to achieve multi-threading, the role of the moveToThread function

Subclass QThread to achieve multi-threading. Only the run function of QThread is in the new thread, and all other functions are in the thread generated by QThread. The correct way to start a thread is to call QThread::start() to start it. 1. Steps Subclass QThread; Rewrite run to put time-consuming events into this function for […]

Subclassing QObject+moveToThread

From the previous “QThread Source Code Analysis”, we can see that before Qt4.4, run was a pure virtual function, and QThread must be subclassed to implement the run function. Starting from Qt4.4, QThread no longer supports abstract classes, run calls QThread::exec() by default, no need to subclass QThread, only need to subclass a QObject, and […]

When the window created in DuiLib inherits the window class WindowImplBase and rewrites the function of WindowImplBase, when is the function rewritten by the subclass called?

Article directory foreword 1. In C++, the derived class rewrites the member function of the base class. When the base class calls the member function of the base class, whether the rewritten member function of the derived class is called 2. In C++, the derived class rewrites the member function of the base class virual. […]

C++ template class points to subclass object (146)

Introduction: CSDN blog expert, focusing on Android/Linux system, sharing multi-mic voice solutions, audio and video, codec Waiting for technology, grow together with everyone! High-quality column: Audio Engineer Advanced Series【Original dry goods continue Updating…] Life motto: There is no shortcut in life, only action is the only cure for fear and laziness. More original, welcome to […]

AndroidViewModel is a subclass of ViewModel, you can directly call getApplication(), so you can access the global resources of the application

Combined with SharedPreferences to save data MainActivity.java package com.tjjingpan.study.viewmodelshp; import androidx.appcompat.app.AppCompatActivity; import androidx.databinding.DataBindingUtil; import androidx.lifecycle.SavedStateViewModelFactory; import android.os.Bundle; import com.tjjingpan.study.viewmodelshp.databinding.ActivityMainBinding; public class MainActivity extends AppCompatActivity { MyViewModel myViewModel; ActivityMainBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.activity_main); binding = DataBindingUtil.setContentView(this, R.layout.activity_main); //myViewModel = new MyViewModel(); //myViewModel. application = getApplication(); //myViewModel.context = getApplicationContext(); SavedStateViewModelFactory savedStateViewModelFactory = […]

[C/C++ keyword function specifier] C++ final keyword (decorated member functions cannot be overridden by subclasses)

Directory Title 1. Introduction to C ++ `final` keyword 1.1 The definition and design intent of `final` keyword 2. Usage of `final` keyword 2.1 How to use the `final` keyword in classes and member functions Usage of `final` in class Usage of `final` in member functions 2.2 The relationship between the `final` keyword and virtual […]

1 2 view base classes – 2 5 view extension classes – 3 9 view subclasses – view set – routing component – supplementary points

1 2 view base classes # django built-in View # APIView of drf, inherited from View # GenericAPIView – Two important class attributes: queryset = Book.objects.all() # data to be serialized serializer_class = BookSerializer # Serialization class – Several important methods: self. get_object() self. get_queryset() self. get_serializer(instance=book_list, many=True) 1.1 Use APIView to write five interfaces […]

Liskov Substitution Principle: With inheritance, is the design of the subclass correct?

Foreword In the previous article, we talked about the principle of openness and closure. If we want the system to conform to the principle of openness and closure, the most important thing is that we need to build a corresponding extension model, so we need to program against the interface. Most of the interface-oriented programming […]