كيف يمكنني حل axxess ل "محمي " هدف ؟

برمجة


أحاول التعرف على “المرسل” لوظيفة “الاتصال” في Qt.

ال

int i = RXobject->senderSignalIndex();

تبدو طريقة جيدة لإنجاز مهمتي، لكن…

أحصل على العضو “المحمي” ولا أعرف كيفية المتابعة …

الرجاء تجاهل الكود غير ذي الصلة، هذا “قيد الإنشاء”
وأنا أطرح سؤال C++، لا علاقة له بـ Qt.

سي ++
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 تقديم مثال على “sender

“الاستخدام…لا يوجد حظ

الحل 1

إذا فهمت ما تحاول القيام به، فإنك لا “تحل” هذه الطريقة. لا يمكن الوصول إلى الأعضاء المحميين في الفصل إلا من خلال رمز الفصل نفسه أو من ورثة الفصل، والذي أعتقد أنه QObject.

コメント

タイトルとURLをコピーしました