What has QWidget * QApplication :: mainWidget () become in Qt4?

I am moving the application from Qt3 to Qt4 and need to replace Qt4 for QApplication :: mainWidget (), which was used to return the top-level widget in Qt3. Does anyone know how to do this in Qt4?

+5
source share
3 answers

Technically, any widget initialized with NULL is a top-level widget, so QApplication should not assume that one of them is better than the other.
I usually do this to save a pointer to the "real" main widget somewhere, even a global variable or singleton, and refer to it when necessary.

+3
source

, topLevelWidgets() .

:

. Qt4 ( ). MainWidget. QMainWindows , . , :) , QT3 (yuck!) QApplication.

+2

I think that what you are looking for has been replaced by the QMainWindow class , which allows you to set the set and get center widget.

+1
source

All Articles