本文整理汇总了C++中QTextEdit::setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextEdit::setSizePolicy方法的具体用法?C++ QTextEdit::setSizePolicy怎么用?C++ QTextEdit::setSizePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextEdit
的用法示例。
在下文中一共展示了QTextEdit::setSizePolicy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setMinimumHeight
bool
ResizableMessageBox::event(QEvent *e)
{
bool result = QMessageBox::event(e);
//QMessageBox::event in this case will call setFixedSize on the dialog frame, making it not resizable by the user
if ( (e->type() == QEvent::LayoutRequest) || (e->type() == QEvent::Resize) ) {
setMinimumHeight(0);
setMaximumHeight(QWIDGETSIZE_MAX);
setMinimumWidth(0);
setMaximumWidth(QWIDGETSIZE_MAX);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// make the detailed text expanding
QTextEdit *textEdit = findChild<QTextEdit *>();
if (textEdit) {
textEdit->setMinimumHeight(0);
textEdit->setMaximumHeight(QWIDGETSIZE_MAX);
textEdit->setMinimumWidth(0);
textEdit->setMaximumWidth(QWIDGETSIZE_MAX);
textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
}
return result;
}
示例2: setup
virtual int setup() {
QTextEdit *qw;
uint32_t flags;
GWEN_WIDGET *wParent;
QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
const char *s;
QString text;
QT4_GuiDialog *qtDialog;
flags=GWEN_Widget_GetFlags(_widget);
wParent=GWEN_Widget_Tree_GetParent(_widget);
s=GWEN_Widget_GetText(_widget, 0);
if (s)
text=QString::fromUtf8(s);
qw=new QTextEdit(text);
/* handle flags */
if (flags & GWEN_WIDGET_FLAGS_FILLX)
hpolicy=QSizePolicy::Expanding;
if (flags & GWEN_WIDGET_FLAGS_FILLY)
vpolicy=QSizePolicy::Expanding;
qw->setSizePolicy(hpolicy, vpolicy);
GWEN_Widget_SetImplData(_widget, QT4_DIALOG_WIDGET_REAL, (void*) qw);
qtDialog=dynamic_cast<QT4_GuiDialog*>(getDialog());
assert(qtDialog);
qw->connect(qw, SIGNAL(returnPressed()),
qtDialog->getMainWindow(),
SLOT(slotActivated()));
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, _widget);
return 0;
}
示例3: setModel
void SqlItemView::setModel(QAbstractItemModel * model)
{
m_model = model;
QSqlQueryModel * t = qobject_cast<QSqlQueryModel *>(model);
if (!t) { return; }
QSqlRecord rec(t->record());
if (scrollWidget->widget())
{
delete scrollWidget->takeWidget();
}
QWidget * layoutWidget = new QWidget(scrollWidget);
m_gridLayout = new QGridLayout(layoutWidget);
QString tmp("%1:");
for (int i = 0; i < rec.count(); ++i)
{
m_gridLayout->addWidget(
new QLabel(tmp.arg(rec.fieldName(i)), layoutWidget), i, 0);
QTextEdit * w = new QTextEdit(layoutWidget);
w->setReadOnly(false);
w->setAcceptRichText(false);
int mh = QFontMetrics(w->currentFont()).lineSpacing();
w->setMinimumHeight(mh);
w->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::MinimumExpanding);
m_gridLayout->addWidget(w, i, 1);
m_gridLayout->setRowMinimumHeight(i, mh);
connect(w, SIGNAL(textChanged()),
this, SLOT(textChanged()));
}
scrollWidget->setWidget(layoutWidget);
m_count = rec.count();
}
示例4: if
PmQuery::PmQuery(bool inputflag, bool printflag, bool noframeflag,
bool nosliderflag, bool usesliderflag, bool exclusiveflag)
: QDialog()
{
QHBoxLayout *hboxLayout;
QVBoxLayout *vboxLayout;
QSpacerItem *spacerItem;
QSpacerItem *spacerItem1;
QVBoxLayout *vboxLayout1;
QHBoxLayout *hboxLayout1;
QSpacerItem *spacerItem2;
QString filename;
if (iconic == HOST_ICON)
filename = tr(":images/dialog-host.png");
else if (iconic == ERROR_ICON)
filename = tr(":images/dialog-error.png");
else if (iconic == WARNING_ICON)
filename = tr(":images/dialog-warning.png");
else if (iconic == ARCHIVE_ICON)
filename = tr(":images/dialog-archive.png");
else if (iconic == QUESTION_ICON)
filename = tr(":images/dialog-question.png");
else // (iconic == INFO_ICON)
filename = tr(":images/dialog-information.png");
QIcon icon(filename);
QPixmap pixmap(filename);
setWindowIcon(icon);
setWindowTitle(tr(title));
QGridLayout *gridLayout = new QGridLayout(this);
gridLayout->setSpacing(6);
gridLayout->setMargin(9);
hboxLayout = new QHBoxLayout();
hboxLayout->setSpacing(6);
hboxLayout->setMargin(0);
vboxLayout = new QVBoxLayout();
vboxLayout->setSpacing(6);
vboxLayout->setMargin(0);
spacerItem = new QSpacerItem(20, 2, QSizePolicy::Minimum,
QSizePolicy::Expanding);
vboxLayout->addItem(spacerItem);
QLabel *imageLabel = new QLabel(this);
imageLabel->setPixmap(pixmap);
vboxLayout->addWidget(imageLabel);
spacerItem1 = new QSpacerItem(20, 20, QSizePolicy::Minimum,
QSizePolicy::Expanding);
vboxLayout->addItem(spacerItem1);
hboxLayout->addLayout(vboxLayout);
vboxLayout1 = new QVBoxLayout();
vboxLayout1->setSpacing(6);
vboxLayout1->setMargin(0);
int height;
int width = DEFAULT_EDIT_WIDTH;
QLineEdit* lineEdit = NULL;
QTextEdit* textEdit = NULL;
if (inputflag && messagecount <= 1) {
lineEdit = new QLineEdit(this);
if (messagecount == 1)
lineEdit->setText(tr(messages[0]));
height = lineEdit->font().pointSize() + 4;
if (height < 0)
height = lineEdit->font().pixelSize() + 4;
if (height < 0)
height = lineEdit->heightForWidth(width) + 4;
lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding,
QSizePolicy::Fixed);
lineEdit->setMinimumSize(QSize(width, height));
lineEdit->setGeometry(QRect(0, 0, width, height));
vboxLayout1->addWidget(lineEdit);
}
else {
QFont fixed("monospace");
fixed.setStyleHint(QFont::TypeWriter);
textEdit = new QTextEdit(this);
textEdit->setFont(fixed);
textEdit->setLineWrapMode(QTextEdit::FixedColumnWidth);
textEdit->setLineWrapColumnOrWidth(80);
textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
if (nosliderflag)
textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
else if (usesliderflag)
textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
else
textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
for (int m = 0; m < messagecount; m++)
textEdit->append(tr(messages[m]));
if (inputflag)
textEdit->setReadOnly(false);
else {
textEdit->setLineWidth(1);
//.........这里部分代码省略.........
示例5: keyPressEvent
// -------------------------------------------------------------------------
void ctkQImageView::keyPressEvent( QKeyEvent * event )
{
Q_D( ctkQImageView );
if( d->SliceNumber >= 0 && d->SliceNumber < d->ImageList.size() )
{
switch( event->key() )
{
case Qt::Key_H:
{
QTextEdit * help = new QTextEdit();
help->setWindowFlags( Qt::Window );
help->setMinimumSize( 500, 500 );
help->setSizePolicy( QSizePolicy::Preferred,
QSizePolicy::Preferred );
help->setReadOnly( true );
help->append("<h1>CTK Simple Image Viewer Widget</h1>");
help->append("Contributed by: Kitware, Inc.<br>");
help->append("<h3>Keyboard commands:</h3>");
help->append(" <em>q</em> : quit");
help->append(" <em>h</em> : display this help");
help->append(" <em>i</em> : invert intensities");
help->append(" <em>[ ]</em> : increase / decrease zoom");
help->append(" <em>x y</em> : flip along the x / y axis");
help->append(" <em>r</em> : reset to initial conditions");
help->append(" <em>spacebar</em> : toggle continuous tracking of cursor");
help->append(" <em>up-arrow down-arrow</em> : change to next / previous slice");
help->append("<h3>Mouse commands:</h3>");
help->append(" <em>left-button</em> : window and level");
help->append(" <em>middle-button</em> : zoom");
help->append(" <em>right-button</em> : center");
help->show();
break;
}
case Qt::Key_Space:
{
d->Window->setMouseTracking( ! d->Window->hasMouseTracking() );
break;
}
case Qt::Key_X:
{
this->setFlipXAxis( ! this->flipXAxis() );
break;
}
case Qt::Key_Y:
{
this->setFlipYAxis( ! this->flipYAxis() );
break;
}
case Qt::Key_T:
{
this->setTransposeXY( ! this->transposeXY() );
break;
}
case Qt::Key_BracketRight:
{
this->setZoom( this->zoom() * 1.1 );
break;
}
case Qt::Key_BracketLeft:
{
this->setZoom( this->zoom() * 0.9 );
break;
}
case Qt::Key_I:
{
this->setInvertImage( ! this->invertImage() );
this->update( false, false );
break;
}
case Qt::Key_Q:
{
exit( EXIT_SUCCESS );
break;
}
case Qt::Key_R:
{
this->reset();
break;
}
case Qt::Key_Up:
{
this->setSliceNumber( d->SliceNumber+1 );
break;
}
case Qt::Key_Down:
{
this->setSliceNumber( d->SliceNumber-1 );
break;
}
default:
{
event->ignore();
}
};
}
}