本文整理汇总了C++中QDialog::setObjectName方法的典型用法代码示例。如果您正苦于以下问题:C++ QDialog::setObjectName方法的具体用法?C++ QDialog::setObjectName怎么用?C++ QDialog::setObjectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDialog
的用法示例。
在下文中一共展示了QDialog::setObjectName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testWaitEndedByModalDialog
void WaitForWindowTest::testWaitEndedByModalDialog() {
WaitForWindow waitForWindow("theName");
waitForWindow.setActive(true);
//WaitFor* must be registered in order to be used with QSignalSpy
int waitForStarType = qRegisterMetaType<WaitFor*>("WaitFor*");
QSignalSpy waitEndedSpy(&waitForWindow, SIGNAL(waitEnded(WaitFor*)));
QDialog* modalDialog = new QDialog(mMainWindow); //krazy:exclude=qclasses
modalDialog->setObjectName("theName");
QTimer timerAccept;
timerAccept.setSingleShot(true);
timerAccept.setInterval(1500);
connect(&timerAccept, SIGNAL(timeout()), modalDialog, SLOT(accept()));
//Check that the condition was met before closing the modal dialog to ensure
//that the processing of events or signals is not halted due to being modal.
queueAssertConditionMet(&waitForWindow, &waitEndedSpy, 500);
timerAccept.start();
modalDialog->exec(); //krazy:exclude=crashy
modalDialog->deleteLater();
QVERIFY(waitForWindow.conditionMet());
QCOMPARE(waitEndedSpy.count(), 1);
QVariant argument = waitEndedSpy.at(0).at(0);
QCOMPARE(argument.userType(), waitForStarType);
QCOMPARE(qvariant_cast<WaitFor*>(argument), &waitForWindow);
}
示例2: createWidget
QWidget* WidgetStyle::createWidget(const QString& name)
{
if(name == "CheckBox")
{
QCheckBox* box = new QCheckBox("CheckBox");
box->setObjectName("CheckBox");
return setLayoutWidget({ box }, { 100, 30 });
}
else if(name == "ComboBox")
{
QComboBox* box = new QComboBox;
box->addItem("Item1");
box->addItem("Item3");
box->addItem("Item3");
box->setObjectName("ComboBox");
return setLayoutWidget({ box }, { 70, 30 });
}
else if(name == "DateEdit")
{
QDateEdit* date = new QDateEdit;
date->setObjectName("DateEdit");
return setLayoutWidget({ date }, { 110, 40 });
}
else if(name == "DateTimeEdit")
{
QDateTimeEdit* date = new QDateTimeEdit;
date->setObjectName("DateTimeEdit");
return setLayoutWidget({ date }, { 160, 30 });
}
else if(name == "Dialog")
{
QDialog* dialog = new QDialog;
dialog->setObjectName("Dialog");
return setLayoutWidget({ dialog }, { 160, 110 });
}
else if(name == "DockWidget") //?
{
QDockWidget* widget = new QDockWidget;
widget->setObjectName("DockWidget");
widget->resize(61, 22);
return widget;
}
else if(name == "DoubleSpinBox")
{
QDoubleSpinBox* box = new QDoubleSpinBox;
box->setObjectName("DoubleSpinBox");
return setLayoutWidget({ box }, { 90, 40 });
}
else if(name == "Frame") //??
{
QFrame* frame = new QFrame;
frame->setObjectName("Frame");
frame->resize(150, 100);
return frame;
}
else if(name == "GroupBox")
{
QGroupBox* box = new QGroupBox("GroupBox");
box->setObjectName("GroupBox");
return setLayoutWidget({ box }, { 160, 110 });
}
else if(name == "Label")
{
QLabel* label = new QLabel("Label");
label->setObjectName("Label");
return setLayoutWidget({ label }, { 40, 20});
}
else if(name == "LineEdit")
{
QLineEdit* line = new QLineEdit;
line->setObjectName("LineEdit");
return setLayoutWidget({ line }, { 30, 30 });
}
else if(name == "ListView") //??
{
QListView* view = new QListView;
view->setObjectName("ListView");
view->resize(71, 71);
return view;
}
else if(name == "ListWidget")
{
QListWidget* list = new QListWidget;
list->setObjectName("ListWidget");
for(int i = 0; i < 20; i++)
list->addItem(QString("Item %1").arg(i));
return setLayoutWidget({ list }, { 80, 80 });
}
else if(name == "MainWindow")
{
QMainWindow* window = new QMainWindow;
window->setObjectName("MainWindow");
return setLayoutWidget({ window }, { 160, 110 });
}
else if(name == "Menu")
{
QMenu* parentMenu = new QMenu;
parentMenu->setObjectName("Menu");
parentMenu->addMenu("Menu1");
QMenu* menu1 = parentMenu->addMenu("Menu2");
//.........这里部分代码省略.........