读书人

小弟我刚学习C++ GUI QT4第二章头文件

发布时间: 2012-02-09 18:22:27 作者: rapoo

我刚学习C++ GUI QT4第二章头文件UI_gotocelldialog.h中有个方法在参考手册中没有啊,就下边的objectName()、setObjec
我刚学习C++ GUI QT4第二章头文件UI_gotocelldialog.h中有个方法在参考手册中没有啊,就下边的objectName()、setObjectName(),请各位帮一下忙


#ifndef UI_GOTOCELLDIALOG_H
#define UI_GOTOCELLDIALOG_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>

QT_BEGIN_NAMESPACE

class Ui_GoToCellDialog
{
public:
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
QLabel *label;
QLineEdit *lineEdit;
QHBoxLayout *hboxLayout1;
QSpacerItem *spacerItem;
QPushButton *okButton;
QPushButton *cancelButton;

void setupUi(QWidget *GoToCellDialog)
{
if (GoToCellDialog->objectName().isEmpty())
GoToCellDialog->setObjectName(QString::fromUtf8("GoToCellDialog"));
GoToCellDialog->resize(190, 94);
vboxLayout = new QVBoxLayout(GoToCellDialog);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
hboxLayout = new QHBoxLayout();
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
label = new QLabel(GoToCellDialog);
label->setObjectName(QString::fromUtf8("label"));

hboxLayout->addWidget(label);

lineEdit = new QLineEdit(GoToCellDialog);
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));

hboxLayout->addWidget(lineEdit);


vboxLayout->addLayout(hboxLayout);

hboxLayout1 = new QHBoxLayout();
hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1"));
spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

hboxLayout1->addItem(spacerItem);

okButton = new QPushButton(GoToCellDialog);
okButton->setObjectName(QString::fromUtf8("okButton"));
okButton->setEnabled(false);
okButton->setDefault(true);

hboxLayout1->addWidget(okButton);

cancelButton = new QPushButton(GoToCellDialog);
cancelButton->setObjectName(QString::fromUtf8("cancelButton"));

hboxLayout1->addWidget(cancelButton);


vboxLayout->addLayout(hboxLayout1);

#ifndef QT_NO_SHORTCUT
label->setBuddy(lineEdit);
#endif // QT_NO_SHORTCUT
QWidget::setTabOrder(lineEdit, okButton);
QWidget::setTabOrder(okButton, cancelButton);

retranslateUi(GoToCellDialog);

QMetaObject::connectSlotsByName(GoToCellDialog);
} // setupUi

void retranslateUi(QWidget *GoToCellDialog)
{
GoToCellDialog->setWindowTitle(QApplication::translate("GoToCellDialog", "Go to Cell", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("GoToCellDialog", "&Cell Location:", 0, QApplication::UnicodeUTF8));
okButton->setText(QApplication::translate("GoToCellDialog", "OK", 0, QApplication::UnicodeUTF8));
cancelButton->setText(QApplication::translate("GoToCellDialog", "Cancel", 0, QApplication::UnicodeUTF8));


} // retranslateUi

};

namespace Ui {
class GoToCellDialog: public Ui_GoToCellDialog {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_GOTOCELLDIALOG_H


[解决办法]
objectName()是获取对象的名称,setObjectName是给某一个对象设置名称,手册中有的呀

以下是从帮助手册中找到的,你自己看看吧
objectName : QString
This property holds the name of this object.

You can find an object by name (and type) using findChild(). You can find a set of objects with findChildren().

qDebug("MyClass::setPrecision(): (%s) invalid precision %f",
qPrintable(objectName()), newPrecision);By default, this property contains an empty string.

Access functions:

QString objectName () const
void setObjectName ( const QString & name )

See also metaObject() and QMetaObject::className().

[解决办法]
手册有时你按F1提示你没有相关文档.这时候你可以先按住Ctrl然后点击你要查找的那个方法.跳到定义处后,然后在按F1一般就回有了.或者你直接在帮助里面搜索也可以的.

读书人网 >QT开发

热点推荐