我是一名初学者C ++程序员,正在为我的公司做一个PoC。因此,对于我的基础问题,我深表歉意。
class TestOne{
private:
TestTwo* t2;
void createInstance(TestTwo* param){
t2 = param;
}
static void staticFunctionToAccessT2(){
// Now here I want to access "t2" here in the current instance of the class
// By current instance I mean "this" in non-static context
// currently there is no function to get object, but can be created
// ** we cannot call new TestOne(), because that will create a new instance
// ** of the current class and that I don't want.
}
}
非常感谢您提供的帮助。
谢谢。
===更新内容===
这个场景可以被看作是我在QT Creator中开发应用程序的情况,我有一个预定义签名的静态函数,并想要访问UI元素以更改文本(如TextEdit)。