本文整理汇总了C++中QTextEdit::setWordWrapMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::setWordWrapMode方法的具体用法?C++ QTextEdit::setWordWrapMode怎么用?C++ QTextEdit::setWordWrapMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::setWordWrapMode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wrapDescription
// Extract the wrapped text from a text edit, which performs
// the wrapping only optically.
void SubmitEditorWidget::wrapDescription()
{
if (!lineWrap())
return;
const QChar newLine = QLatin1Char('\n');
QTextEdit e;
e.setVisible(false);
e.setMinimumWidth(1000);
e.setFontPointSize(1.0);
e.setLineWrapColumnOrWidth(d->m_ui.description->lineWrapColumnOrWidth());
e.setLineWrapMode(d->m_ui.description->lineWrapMode());
e.setWordWrapMode(d->m_ui.description->wordWrapMode());
e.setPlainText(d->m_description);
d->m_description.clear();
QTextCursor cursor(e.document());
cursor.movePosition(QTextCursor::Start);
while (!cursor.atEnd()) {
const QString block = cursor.block().text();
if (block.startsWith(QLatin1Char('\t'))) { // Don't wrap
d->m_description += block + newLine;
cursor.movePosition(QTextCursor::EndOfBlock);
} else {
forever {
cursor.select(QTextCursor::LineUnderCursor);
d->m_description += cursor.selectedText();
d->m_description += newLine;
cursor.clearSelection();
if (cursor.atBlockEnd())
break;
cursor.movePosition(QTextCursor::NextCharacter);
}
}
cursor.movePosition(QTextCursor::NextBlock);
}
}
示例2: createLogPage
QTextEdit* VBoxVMLogViewer::createLogPage (const QString &aName)
{
QWidget *pageContainer = new QWidget();
QVBoxLayout *pageLayout = new QVBoxLayout (pageContainer);
QTextEdit *logViewer = new QTextEdit (pageContainer);
pageLayout->addWidget (logViewer);
pageLayout->setContentsMargins (10, 10, 10, 10);
QFont font = logViewer->currentFont();
font.setFamily ("Courier New,courier");
logViewer->setFont (font);
logViewer->setWordWrapMode (QTextOption::NoWrap);
logViewer->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
logViewer->setReadOnly (true);
mLogList->addTab (pageContainer, aName);
return logViewer;
}
示例3: initUi
void PsiTipLabel::initUi()
{
margin = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this);
setFrameStyle(QFrame::NoFrame);
// doc = new QTextDocument(this);
// QTextDocumentLayout is private in Qt4
// and it's impossible to set wrapping mode directly.
// So we create this QTextEdit instance and use its QTextDocument,
// just because QTextEdit can set the wrapping mode.
// Yes, this is crazy...
QTextEdit *edit = new QTextEdit(this);
edit->hide();
edit->setWordWrapMode(QTextOption::WordWrap);
doc = edit->document();
doc->setUndoRedoEnabled(false);
doc->setDefaultFont(font());
ensurePolished();
setText(theText_);
}
示例4: QWidget
TrayNotificationWidget::TrayNotificationWidget(QPixmap pixmapIcon, QString headerText, QString messageText) : QWidget(0)
{
setWindowFlags(
#ifdef Q_OS_MAC
Qt::SubWindow | // This type flag is the second point
#else
Qt::Tool |
#endif
Qt::FramelessWindowHint |
Qt::WindowSystemMenuHint |
Qt::WindowStaysOnTopHint
);
setAttribute(Qt::WA_NoSystemBackground, true);
// set the parent widget's background to translucent
setAttribute(Qt::WA_TranslucentBackground, true);
//setAttribute(Qt::WA_ShowWithoutActivating, true);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
// create a display widget for displaying child widgets
QWidget* displayWidget = new QWidget;
displayWidget->setStyleSheet(".QWidget { background-color: rgba(0, 0, 0, 75%); border-width: 1px; border-style: solid; border-radius: 10px; border-color: #555555; } .QWidget:hover { background-color: rgba(68, 68, 68, 75%); border-width: 2px; border-style: solid; border-radius: 10px; border-color: #ffffff; }");
QLabel* icon = new QLabel;
icon->setPixmap(pixmapIcon);
icon->setMaximumSize(32, 32);
QLabel* header = new QLabel;
header->setMaximumSize(250, 50);
header->setWordWrap(true);
header->setText(headerText);
header->setStyleSheet("QLabel { color: #ffffff; font-weight: bold; font-size: 12px; }");
QTextEdit *message = new QTextEdit;
message->setReadOnly(true);
message->setFrameStyle(QFrame::NoFrame);
message->setLineWrapMode(QTextEdit::WidgetWidth);
message->setWordWrapMode(QTextOption::WrapAnywhere);
QPalette pal = palette();
pal.setColor(QPalette::Base, Qt::transparent);
message->setPalette(pal);
message->setStyleSheet("QTextEdit { color: #ffffff; font-size: 10px; }");
message->setText(messageText);
message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QVBoxLayout* vl = new QVBoxLayout;
vl->addWidget(header);
vl->addWidget(message);
QHBoxLayout* displayMainLayout = new QHBoxLayout;
displayMainLayout->addWidget(icon);
displayMainLayout->addLayout(vl);
displayWidget->setLayout(displayMainLayout);
QHBoxLayout* containerLayout = new QHBoxLayout;
containerLayout->addWidget(displayWidget);
setLayout(containerLayout);
show();
setMinimumHeight((int)(message->document()->size().height() *1.5 + header->height() +70));
timeout = new QTimer(this);
connect(timeout, SIGNAL(timeout()), this, SLOT(fadeOut()));
timeout->start(3000);
}
示例5: pix
//.........这里部分代码省略.........
infoString += KviRuntimeInfo::machine();
infoString += "<br>";
infoString += __tr2qs_ctx("Qt version","about");
infoString += ": ";
infoString += KviRuntimeInfo::qtVersion();
infoString += "<br>";
infoString += __tr2qs_ctx("Qt theme","about");
infoString += ": ";
infoString += KviRuntimeInfo::qtTheme();
infoString += "<br><br>";
infoString += "<b>";
infoString += __tr2qs_ctx("Build Info","about");
infoString += ":</b><br>";
infoString += __tr2qs_ctx("Build date","about");
infoString += ": ";
infoString += KviBuildInfo::buildDate();
infoString += "<br>";
infoString += __tr2qs_ctx("Sources date","about");
infoString += ": ";
infoString += KviBuildInfo::buildSourcesDate();
infoString += "<br>";
infoString += __tr2qs_ctx("Revision number","about");
infoString += ": ";
infoString += KviBuildInfo::buildRevision();
infoString += "<br>";
infoString += __tr2qs_ctx("System name","about");
infoString += ": ";
infoString += KviBuildInfo::buildSystem();
infoString += "<br>";
infoString += __tr2qs_ctx("CPU name","about");
infoString += ": ";
infoString += KviBuildInfo::buildCPU();
infoString += "<br>";
infoString += __tr2qs_ctx("Build command","about");
infoString += ": ";
infoString += KviBuildInfo::buildCommand();
infoString += "<br>";
infoString += __tr2qs_ctx("Build flags","about");
infoString += ": <br> ";
QString flags = KviBuildInfo::buildFlags();
infoString += flags.replace(QRegExp(";"),"<br> ");
infoString += "<br>";
infoString += __tr2qs_ctx("Compiler name","about");
infoString += ": ";
infoString += KviBuildInfo::buildCompiler();
infoString += "<br>";
infoString += __tr2qs_ctx("Compiler flags","about");
infoString += ": ";
infoString += KviBuildInfo::buildCompilerFlags();
infoString += "<br>";
infoString += __tr2qs_ctx("Qt version","about");
infoString += ": ";
infoString += KviBuildInfo::qtVersion();
v->setText(infoString);
addTab(w,__tr2qs_ctx("Executable Information","about"));
// Honor & Glory tab
w = new QWidget(this);
g = new QGridLayout(w);
v = new QTextEdit(w);
v->setReadOnly(true);
g->addWidget(v,0,0);
v->setText(g_szAboutText);
addTab(w,__tr2qs_ctx("Honor && Glory","about"));
// License tab
w = new QWidget(this);
g = new QGridLayout(w);
v = new QTextEdit(w);
v->setReadOnly(true);
v->setWordWrapMode(QTextOption::NoWrap);
g->addWidget(v,0,0);
QString szLicense;
QString szLicensePath;
g_pApp->getGlobalKvircDirectory(szLicensePath,KviApplication::License,"COPYING");
if(!KviFileUtils::loadFile(szLicensePath,szLicense))
{
szLicense = __tr2qs_ctx("Oops! Can't find the license file.\n" \
"It MUST be included in the distribution...\n" \
"Please report to <pragma at kvirc dot net>","about");
}
v->setText(szLicense);
addTab(w,__tr2qs_ctx("License","about"));
connect(this,SIGNAL(applyButtonPressed()),this,SLOT(closeButtonPressed()));
}
示例6: refresh
void VBoxVMLogViewer::refresh()
{
/* Clearing old data if any */
mLogFiles.clear();
mLogList->setEnabled (true);
while (mLogList->count())
{
QWidget *firstPage = mLogList->widget (0);
mLogList->removeTab (0);
delete firstPage;
}
bool isAnyLogPresent = false;
const CSystemProperties &sys = vboxGlobal().virtualBox().GetSystemProperties();
int cMaxLogs = sys.GetLogHistoryCount();
for (int i=0; i <= cMaxLogs; ++i)
{
/* Query the log file name for index i */
QString file = mMachine.QueryLogFilename(i);
if (!file.isEmpty())
{
/* Try to read the log file with the index i */
ULONG uOffset = 0;
QString text;
while (true)
{
QVector<BYTE> data = mMachine.ReadLog(i, uOffset, _1M);
if (data.size() == 0)
break;
text.append(QString::fromUtf8((char*)data.data(), data.size()));
uOffset += data.size();
}
/* Anything read at all? */
if (uOffset > 0)
{
/* Create a log viewer page and append the read text to it */
QTextEdit *logViewer = createLogPage(QFileInfo(file).fileName());
logViewer->setPlainText(text);
/* Add the actual file name and the QTextEdit containing the
content to a list. */
mLogFiles << qMakePair(file, logViewer);
isAnyLogPresent = true;
}
}
}
/* Create an empty log page if there are no logs at all */
if (!isAnyLogPresent)
{
QTextEdit *dummyLog = createLogPage ("VBox.log");
dummyLog->setWordWrapMode (QTextOption::WordWrap);
dummyLog->setHtml (tr ("<p>No log files found. Press the "
"<b>Refresh</b> button to rescan the log folder "
"<nobr><b>%1</b></nobr>.</p>")
.arg (mMachine.GetLogFolder()));
/* We don't want it to remain white */
QPalette pal = dummyLog->palette();
pal.setColor (QPalette::Base, pal.color (QPalette::Window));
dummyLog->setPalette (pal);
}
/* Show the first tab widget's page after the refresh */
mLogList->setCurrentIndex (0);
currentLogPageChanged (0);
/* Enable/Disable save button & tab widget according log presence */
mBtnFind->setEnabled (isAnyLogPresent);
mBtnSave->setEnabled (isAnyLogPresent);
mLogList->setEnabled (isAnyLogPresent);
/* Default to the save button if there are any log files otherwise to the
* close button. The initial automatic of the main dialog has to be
* overwritten */
setDefaultButton (isAnyLogPresent ? mBtnSave:mBtnClose);
}