vql
16th November 2007, 12:48
I want to develop some widgets for my project, I read Qt's widget source code & have some questions in programming:
1. The constructor of QAbstractButton:
explicit QAbstractButton (QWidget *parent = 0)
What is the purpose and the meaning to using the keyword explicit in constructor?
2. In the function QToolButtonPrivate::popupTimerDone(), some commands I don't understand:
QPointer<QMenu> actualMenu; //the type of actualMenu is'n a pointer
...
if (...)
actualMenu = menuAction->menu();
else
actualMenu = new QMenu(q); //but in this code, it used as a pointer
3. The relationship between QToolButton & QToolButtonPrivate (similar for other classes).
4. Using macro:
#define QTTR_NOOP(x) (x) // this macro has the result
#define Q_DOC_PROPERTY(text) // but this macro doesn't have the result
#define Q_D(Class) Class##Private *const d=d_func()
#define Q_Q(Class) Class *const q=q_func()
I don't understand the declare of these macros. Please explain it.
Thanks alot.
1. The constructor of QAbstractButton:
explicit QAbstractButton (QWidget *parent = 0)
What is the purpose and the meaning to using the keyword explicit in constructor?
2. In the function QToolButtonPrivate::popupTimerDone(), some commands I don't understand:
QPointer<QMenu> actualMenu; //the type of actualMenu is'n a pointer
...
if (...)
actualMenu = menuAction->menu();
else
actualMenu = new QMenu(q); //but in this code, it used as a pointer
3. The relationship between QToolButton & QToolButtonPrivate (similar for other classes).
4. Using macro:
#define QTTR_NOOP(x) (x) // this macro has the result
#define Q_DOC_PROPERTY(text) // but this macro doesn't have the result
#define Q_D(Class) Class##Private *const d=d_func()
#define Q_Q(Class) Class *const q=q_func()
I don't understand the declare of these macros. Please explain it.
Thanks alot.