当前位置: 首页>>代码示例>>C++>>正文


C++ QTextEdit::setObjectName方法代码示例

本文整理汇总了C++中QTextEdit::setObjectName方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::setObjectName方法的具体用法?C++ QTextEdit::setObjectName怎么用?C++ QTextEdit::setObjectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTextEdit的用法示例。


在下文中一共展示了QTextEdit::setObjectName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initTextEditor

void MainWindow::initTextEditor()
{
    //create tab
    QWidget *tab = new QWidget(this);
    QString objName = QString("tab"),
            fileName = "";
    tab->setObjectName(objName);
    //create layout
    QHBoxLayout *layout = new QHBoxLayout(tab);
    layout->setSpacing(0);
    layout->setContentsMargins(11, 11, 11, 11);
    layout->setObjectName(QString("horizontalLayout"));
    layout->setContentsMargins(0, 0, 0, 0);

    //create textedit
    QTextEdit *edit = new QTextEdit(tab);
    edit->setObjectName(QString("textEdit"));

    layout->addWidget(edit);
    ui->tabs->addWidget(tab);

    //slot and signal
    //font change signal
    connect(edit, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
            this, SLOT(currentCharFormatChanged(QTextCharFormat)));
    connect(edit, SIGNAL(cursorPositionChanged()),
            this, SLOT(cursorPositionChanged()));

    //modification
    connect(edit->document(), SIGNAL(modificationChanged(bool)),
            ui->actionSave, SLOT(setEnabled(bool)));
    connect(edit->document(), SIGNAL(modificationChanged(bool)),
            this, SLOT(setWindowModified(bool)));
    connect(edit->document(), SIGNAL(undoAvailable(bool)),
            ui->actionUndo, SLOT(setEnabled(bool)));
    connect(edit->document(), SIGNAL(redoAvailable(bool)),
            ui->actionRedo, SLOT(setEnabled(bool)));

    //redo undo
    connect(ui->actionUndo, SIGNAL(triggered()), edit, SLOT(undo()));
    connect(ui->actionRedo, SIGNAL(triggered()), edit, SLOT(redo()));

    //cut copy paste
    connect(ui->actionCut, SIGNAL(triggered()), edit, SLOT(cut()));
    connect(ui->actionCopy, SIGNAL(triggered()), edit, SLOT(copy()));
    connect(ui->actionPaste, SIGNAL(triggered()), edit, SLOT(paste()));

    connect(edit, SIGNAL(copyAvailable(bool)), ui->actionCut, SLOT(setEnabled(bool)));
    connect(edit, SIGNAL(copyAvailable(bool)), ui->actionCopy, SLOT(setEnabled(bool)));

    textEditor.tab = tab;
    textEditor.editor = edit;
    textEditor.layout = layout;
    textEditor.objName = objName;
    textEditor.fileName = fileName;
}
开发者ID:KanagiMiss,项目名称:testassist,代码行数:56,代码来源:mainwindow.cpp

示例2: Handle

	void ItemHandlerMultiLine::Handle (const QDomElement& item,
			QWidget *pwidget)
	{
		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());
		QLabel *label = new QLabel (XSD_->GetLabel (item));
		label->setWordWrap (false);

		const QVariant& value = XSD_->GetValue (item);

		QTextEdit *edit = new QTextEdit ();
		XSD_->SetTooltip (edit, item);
		edit->setPlainText (value.toStringList ().join ("\n"));
		edit->setObjectName (item.attribute ("property"));
		edit->setMinimumWidth (QApplication::fontMetrics ()
				.width ("thisismaybeadefaultsetting"));
		connect (edit,
				SIGNAL (textChanged ()),
				this,
				SLOT (updatePreferences ()));

		edit->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
		edit->setProperty ("SearchTerms", label->text ());

		int row = lay->rowCount ();
		QString pos = item.attribute ("position");
		if (pos == "bottom")
		{
			lay->addWidget (label, row, 0, Qt::AlignLeft);
			lay->addWidget (edit, row + 1, 0);
		}
		else if (pos == "right")
		{
			lay->addWidget (label, row, 0, Qt::AlignRight | Qt::AlignTop);
			lay->addWidget (edit, row, 1);
		}
		else if (pos == "left")
		{
			lay->addWidget (label, row, 1, Qt::AlignLeft | Qt::AlignTop);
			lay->addWidget (edit, row, 0);
		}
		else if (pos == "top")
		{
			lay->addWidget (edit, row, 0);
			lay->addWidget (label, row + 1, 0, Qt::AlignLeft);
		}
		else
		{
			lay->addWidget (label, row, 0, Qt::AlignRight | Qt::AlignTop);
			lay->addWidget (edit, row, 1);
		}

		lay->setContentsMargins (2, 2, 2, 2);
	}
开发者ID:ForNeVeR,项目名称:leechcraft,代码行数:53,代码来源:itemhandlermultiline.cpp

示例3: createNewTab

void Listening::createNewTab(QString name)
{
    QWidget *widget = new QWidget();
    widget->setObjectName(QStringLiteral("TAB_TOTO"));

    QVBoxLayout *vertLayout = new QVBoxLayout(widget);
    vertLayout->setSpacing(6);
    vertLayout->setContentsMargins(11, 11, 11, 11);
    vertLayout->setObjectName(QStringLiteral("verticalLayout_14"));

    QTextEdit *textEdit = new QTextEdit(widget);
    textEdit->setObjectName(QStringLiteral("textEdit2"));
    textEdit->setTextInteractionFlags(Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse);

    vertLayout->addWidget(textEdit);

    widget->show();

    this->mainWindow->getUi()->QTabWidget_onglets->addTab(widget, name);
}
开发者ID:jerem3189,项目名称:ChatReparti,代码行数:20,代码来源:Listening.cpp

示例4: 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");
//.........这里部分代码省略.........
开发者ID:kissofblood,项目名称:September,代码行数:101,代码来源:widgetstyle.cpp

示例5: if

static QList<QWidget*> getFormWidgets(QList<FormField> formFields, const QObject *receiver)
{
    QList<QWidget*> formWidgets;

    for (int i = 0; i < formFields.size(); ++i)
    {
        Poppler::FormField *formField = formFields.at(i).field;
        if (formField->type() == Poppler::FormField::FormText)
        {
            Poppler::FormFieldText *formFieldText = static_cast<Poppler::FormFieldText*>(formField);
            switch (formFieldText->textType())
            {
            case Poppler::FormFieldText::FileSelect:
            {
                // TODO replace this by a file selection widget
                QLineEdit *lineEdit = new QLineEdit;
                lineEdit->setText(formFieldText->text());
                lineEdit->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
                QObject::connect(lineEdit, SIGNAL(textEdited(QString)), receiver, SLOT(slotSetFormData(QString)));
                formWidgets << lineEdit;
            }
            break;
            case Poppler::FormFieldText::Multiline:
            {
                QTextEdit *textEdit = new QTextEdit;
                textEdit->setText(formFieldText->text());
                textEdit->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
                QObject::connect(textEdit, SIGNAL(textChanged()), receiver, SLOT(slotSetFormData()));
                formWidgets << textEdit;
            }
            break;
            case Poppler::FormFieldText::Normal:
            default:
            {
                QLineEdit *lineEdit = new QLineEdit;
                lineEdit->setText(formFieldText->text());
                lineEdit->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
                QObject::connect(lineEdit, SIGNAL(textEdited(QString)), receiver, SLOT(slotSetFormData(QString)));
                formWidgets << lineEdit;
            }
            break;
            }
        }
        else if (formField->type() == Poppler::FormField::FormButton)
        {
            Poppler::FormFieldButton *formFieldButton = static_cast<Poppler::FormFieldButton*>(formField);
            switch (formFieldButton->buttonType())
            {
            case Poppler::FormFieldButton::CheckBox:
            {
                QCheckBox *checkBox = new QCheckBox;
//						checkBox->setText(formFieldButton->caption());
                checkBox->setChecked(formFieldButton->state());
                checkBox->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
                QObject::connect(checkBox, SIGNAL(toggled(bool)), receiver, SLOT(slotSetFormData(bool)));
                formWidgets << checkBox;
            }
            break;
            case Poppler::FormFieldButton::Radio:
            {
                QRadioButton *radioButton = new QRadioButton;
                radioButton->setText(formFieldButton->caption());
                radioButton->setChecked(formFieldButton->state());
                radioButton->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
                QObject::connect(radioButton, SIGNAL(toggled(bool)), receiver, SLOT(slotSetFormData(bool)));
                formWidgets << radioButton;
            }
            break;
            case Poppler::FormFieldButton::Push:
            default:
            {
                QPushButton *pushButton = new QPushButton;
                pushButton->setText(formFieldButton->caption());
                pushButton->setChecked(formFieldButton->state());
                pushButton->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
                QObject::connect(pushButton, SIGNAL(toggled(bool)), receiver, SLOT(slotSetFormData(bool)));
                formWidgets << pushButton;
            }
            break;
            }
        }
        else if (formField->type() == Poppler::FormField::FormChoice)
        {
            Poppler::FormFieldChoice *formFieldChoice = static_cast<Poppler::FormFieldChoice*>(formField);
            switch (formFieldChoice->choiceType())
            {
            case Poppler::FormFieldChoice::ComboBox:
            {
                QComboBox *comboBox = new QComboBox;
                comboBox->addItems(formFieldChoice->choices());
                comboBox->setEditable(formFieldChoice->isEditable());
                comboBox->setCurrentIndex(formFieldChoice->currentChoices().at(0));
                comboBox->setObjectName(QLatin1String("PageItem::formField") + QString::number(i));
                QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), receiver, SLOT(slotSetFormData(int)));
                formWidgets << comboBox;
            }
            break;
            case Poppler::FormFieldChoice::ListBox:
            default:
            {
//.........这里部分代码省略.........
开发者ID:damoguyan,项目名称:pdfviewer,代码行数:101,代码来源:pageitem.cpp


注:本文中的QTextEdit::setObjectName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。