metaObject()->className() doesn't find QLabel
Unsolved
General and Desktop
-
Hello!
I am using the following code to find all QLayouts within a main layout and then all widgets within those layouts.
if(!allSubLayouts.empty()) { int size = allSubLayouts.size(); for(int i = 0; i < size; i ++) // this loop hides all of the layouts that are currently present. If there are no layouts, nothing happens { for(int j = 0; j < allSubLayouts.at(i)->count(); ++j) { QWidget *w = allSubLayouts.at(i)->itemAt(j)->widget(); if(w != NULL) { qDebug() << "The className of the object is " ; qDebug() << allSubLayouts.at(i)->itemAt(j)->widget()->metaObject()->className(); w->setVisible(false); //delete w; } } }
When I run the code, everything except the
QLabel
classnames are displayed in theqDebug
statement.Why doesn't
widget()->metaObject()->className();
produce QLabels? -
Hello!
I am using the following code to find all QLayouts within a main layout and then all widgets within those layouts.
if(!allSubLayouts.empty()) { int size = allSubLayouts.size(); for(int i = 0; i < size; i ++) // this loop hides all of the layouts that are currently present. If there are no layouts, nothing happens { for(int j = 0; j < allSubLayouts.at(i)->count(); ++j) { QWidget *w = allSubLayouts.at(i)->itemAt(j)->widget(); if(w != NULL) { qDebug() << "The className of the object is " ; qDebug() << allSubLayouts.at(i)->itemAt(j)->widget()->metaObject()->className(); w->setVisible(false); //delete w; } } }
When I run the code, everything except the
QLabel
classnames are displayed in theqDebug
statement.Why doesn't
widget()->metaObject()->className();
produce QLabels?