[ad_1]
我正在尝试识别 Qt“连接”功能的“发送者”。
这
int i = RXobject->senderSignalIndex();
似乎是完成我的任务的好方法,但是……
我得到了“受保护”成员,但不知道如何继续……
请忽略不相关的代码,这是“正在建设中”
我问的是C++问题,与Qt无关。
C++
void MainWindow_Bluetooth::processMenu(int index_submenu, int index_mainmenu) { #ifdef LAMBDA text = "TASK DEBUG connect... "; //connect text += Q_FUNC_INFO; text += QString::number(__LINE__); // move index to class !!! text += " main loop index_main "; text += QString::number(index_mainmenu); text += " embeded loop index_sub "; text += QString::number(index_submenu); text += " main loop class passed index "; text += QString::number(index); qDebug() << text; #endif {// analyze indexes received block QString text; QObject *RXobject = sender(); RXobject->dumpObjectInfo(); QObjectList children = RXobject->children(); //; text = RXobject->children().at(0); //QObjectList *RXChildren = RXobject->children(); //QObject *RXparent = RXobject->parent(); //QObject *TEST_parent = RXparent->parent(); // protected member ??? int i = RXobject->senderSignalIndex(); //int SenderIndex = RXobject::senderSignalIndex(); //text = RXobject->dumpObjectInfo(); text = Q_FUNC_INFO; qDebug() << text;
/mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:3890: error: 'senderSignalIndex' is a protected member of 'QObject' mainwindow_Bluetooth_copy.cpp:3890:19: error: 'senderSignalIndex' is a protected member of 'QObject' int i = RXobject->senderSignalIndex(); ^ /home/nov25-1/Qt/5.15.2/gcc_64/include/QtCore/qobject.h:435:9: note: can only access this member on an object of type 'MainWindow_Bluetooth' int senderSignalIndex() const; ^
我尝试过的:
请 Google 女士提供“发件人
“用法…运气不好
解决方案1
如果我理解你想要做什么,你就不会“解决”该方法。 类的受保护成员只能从类代码本身或类的继承者(我认为是 QObject)访问。
[ad_2]
コメント