Back to "sender()" analysis...
Unsolved
General and Desktop
-
RTFM on "sender()" is a challenge...
dumpObjectInfo(); returns "void" and outputs to "debug" ...?Any way to get it to output to real debug
such as " text " - qDebug() << text ?QObject *RXobject = sender(); RXobject->dumpObjectInfo();
Addendum
How can I fix this:
/mnt/A_BT_DEC10/BT__PROGRAMS/A_JAN11/A_BT_LIBRARY/terminal_Bluetooth/mainwindow_Bluetooth_copy.cpp:3884: error: 'senderSignalIndex' is a protected member of 'QObject' mainwindow_Bluetooth_copy.cpp:3884: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; ^
and why I cannot use it "inside " this function ?
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 QObject *RXobject = sender(); RXobject->dumpObjectInfo(); **int i = RXobject->senderSignalIndex();** // int SenderIndex = RXobject::​senderSignalIndex(); //text = RXobject->dumpObjectInfo(); text += Q_FUNC_INFO; qDebug() << text; //#ifdef LAMBDA
-
Christian Ehrlicher Lifetime Qt Championreplied to Anonymous_Banned275 on 24 Jan 2024, 16:43 last edited by
Maybe reading some c++ basics will help here: https://www.w3schools.com/cpp/cpp_access_specifiers.asp
-
@AnneRanch Here is my latest code , it seems to "navigate " up- stream as far as menus goes...
QObject *RXobject = sender(); RXobject->dumpObjectInfo(); QObject *RXparent = RXobject->parent(); main "windows" menu QObject *TEST_parent = RXparent->parent(); main mdiArea menu
-
@AnneRanch said in Back to "sender()" analysis...:
How can I fix this:
sender()
always returns aQObject *
.
If you want to access members of a class inheriting fromQObject
, e.g.MainWindow_Bluetooth
,qobject_cast
is your friend. It's documentation is here.
1/4