本文整理汇总了C++中QTextEdit::viewport方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::viewport方法的具体用法?C++ QTextEdit::viewport怎么用?C++ QTextEdit::viewport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::viewport方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawShape
void DPText::drawShape( QPainter &p )
{
QRect bound = m_sizeRect;
bound.setWidth( bound.width()-2 );
bound.setHeight( bound.height()-2 );
bound.translate( int(x()+1), int(y()+1) );
if (b_displayBackground)
{
p.save();
p.setPen( QPen( m_frameColor, 1, Qt::DotLine) );
p.setBrush(m_backgroundColor);
p.drawRect(bound);
p.restore();
}
const int pad = 6;
bound.setLeft( bound.left()+pad );
bound.setTop( bound.top() );
bound.setRight( bound.right()-pad );
bound.setBottom( bound.bottom()-pad );
QTextEdit * t = new QTextEdit( m_text );
t->resize( bound.width(), bound.height() ); // t->setWidth( bound.width() );
t->viewport()->setAutoFillBackground( false );
t->setFrameStyle(QFrame::NoFrame);
t->render( &p, bound.topLeft(), QRegion(), QWidget::DrawChildren ); //t->draw( &p, bound.left(), bound.top(), bound, QColorGroup() );
delete t;
}
示例2: fileNew
void TextEdit::fileNew()
{
QTextEdit *edit = new QTextEdit( tabWidget );
doConnections( edit );
tabWidget->addTab( edit, tr( "noname" ) );
tabWidget->showPage( edit );
edit->viewport()->setFocus();
}
示例3: load
void TextEdit::load( const QString &f )
{
if ( !QFile::exists( f ) )
return;
QTextEdit *edit = new QTextEdit( tabWidget );
doConnections( edit );
tabWidget->addTab( edit, QFileInfo( f ).fileName() );
QFile fl( f );
fl.open( IO_ReadOnly );
QByteArray array = fl.readAll();
array.resize( array.size() +1 );
array[ (int)array.size() - 1 ] = '\0';
QString text = ( f.find( "bidi.txt" ) != -1 ? QString::fromUtf8( array.data() ) : QString::fromLatin1( array.data() ) );
edit->setText( text );
edit->viewport()->setFocus();
edit->setTextFormat( Qt::RichText );
}
示例4: load
void TextEdit::load( const QString &f )
{
if ( !QFile::exists( f ) )
return;
QTextEdit *edit = new QTextEdit( tabWidget );
edit->setTextFormat( RichText );
doConnections( edit );
tabWidget->addTab( edit, QFileInfo( f ).fileName() );
QFile file( f );
if ( !file.open( IO_ReadOnly ) )
return;
QTextStream ts( &file );
QString txt = ts.read();
if ( !QStyleSheet::mightBeRichText( txt ) )
txt = QStyleSheet::convertFromPlainText( txt, QStyleSheetItem::WhiteSpacePre );
edit->setText( txt );
tabWidget->showPage( edit );
edit->viewport()->setFocus();
filenames.replace( edit, f );
}