本文整理汇总了C++中QWidget::adjustSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::adjustSize方法的具体用法?C++ QWidget::adjustSize怎么用?C++ QWidget::adjustSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::adjustSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QFrame
OptionWidget::OptionWidget(const QString &title, QWidget *mainWidget, QWidget *parent) : QFrame(parent), mainWidget(mainWidget), isFolded(true) {
setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
setMinimumWidth(300);
moveButton = new BorderlessToolButton("images/Move.png", this);
moveButton->setDragging(true);
connect(moveButton, SIGNAL(dragEvent(QMouseEvent*)), this, SLOT(dragEvent(QMouseEvent*)));
foldInButton = new BorderlessToolButton("images/ArrowUp.png", this);
connect(foldInButton, SIGNAL(clicked()), this, SLOT(toggleFolding()));
foldOutButton = new BorderlessToolButton("images/ArrowDown.png", this);
connect(foldOutButton, SIGNAL(clicked()), this, SLOT(toggleFolding()));
closeButton = new BorderlessToolButton("images/Close.png", this);
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
QHBoxLayout *controlsLayout = new QHBoxLayout;
controlsLayout->setMargin(0);
controlsLayout->setAlignment(Qt::AlignRight | Qt::AlignTop);
controlsLayout->addWidget(moveButton);
controlsLayout->addWidget(foldInButton);
controlsLayout->addWidget(foldOutButton);
controlsLayout->addWidget(closeButton);
QWidget *controlsWidget = new QWidget;
controlsWidget->setLayout(controlsLayout);
controlsWidget->adjustSize();
controlsWidget->update();
QHBoxLayout *titleLayout = new QHBoxLayout;
titleLayout->setMargin(0);
titleLayout->addWidget(new QLabel(title));
titleLayout->addWidget(controlsWidget);
QWidget *titleWidget = new QWidget;
titleWidget->setLayout(titleLayout);
titleWidget->adjustSize();
titleWidget->update();
separatorLine = new QFrame;
separatorLine->setFrameShape(QFrame::HLine);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(titleWidget);
layout->addWidget(separatorLine);
layout->addWidget(mainWidget);
toggleFolding();
layout->update();
setLayout(layout);
};
示例2: setTabItemCount
void TabBar::setTabItemCount(const QString &tabName, const QString &itemCount)
{
const int i = tabIndex(tabName, *this);
if (i == -1)
return;
QWidget *tabCountLabel = tabButton(i, QTabBar::RightSide);
if ( itemCount.isEmpty() ) {
if (tabCountLabel) {
tabCountLabel->deleteLater();
setTabButton(i, QTabBar::RightSide, nullptr);
}
} else {
if (!tabCountLabel) {
tabCountLabel = new QLabel(this);
tabCountLabel->setObjectName("tab_item_counter");
setDefaultTabItemCounterStyle(tabCountLabel);
setTabButton(i, QTabBar::RightSide, tabCountLabel);
}
tabCountLabel->setProperty("text", itemCount);
tabCountLabel->adjustSize();
}
updateTabStyle(i);
}
示例3: fillView
void TaskMTRTableView::fillView()
{
TaskMTRTable *g = (TaskMTRTable *)node();
ui->tableWidget->setColumnCount(g->columns().count());
int rowcount = 0;
for(int i=0; i<g->columns().count(); ++i)
if (g->columns().at(i).count()>rowcount)
rowcount = g->columns().at(i).count();
ui->tableWidget->setRowCount(rowcount);
ui->tableWidget->setHorizontalHeaderLabels(g->columnTitles());
for(int i=0; i<g->columns().count(); ++i)
{
for(int j=0; j<g->columns().at(i).count(); ++j)
{
QWidget *widget = cell(g->columns().at(i)[j]);
widget->adjustSize();
if (widget->width() > ui->tableWidget->columnWidth(i))
ui->tableWidget->setColumnWidth(i, widget->width());
if (widget->height() > ui->tableWidget->rowHeight(j))
ui->tableWidget->setRowHeight(j, widget->height());
ui->tableWidget->setItem(j,i, new QTableWidgetItem());
ui->tableWidget->setCellWidget(j, i, widget);
}
for(int j=g->columns().at(i).count(); j<ui->tableWidget->rowCount(); ++j)
{
QTableWidgetItem *item = new QTableWidgetItem();
item->setFlags(0);
ui->tableWidget->setItem(j, i, item);
}
}
}
示例4: resizeBarDragged
void ReportSection::resizeBarDragged(int delta) {
if(canvasview->document() && canvasview->document()->pageOptions
&& canvasview->document()->pageOptions->getPageSize() == "Labels") {
return; // we don't want to allow this on reports that are for labels
}
int h = canvas->height() + delta;
if(h < 1) h = 1;
if(grid->isSnap()) {
int incr = (int)(grid->yInterval() * dpiY);
int nh = (h / incr) * incr;
if(nh == 0) nh = incr;
h = nh;
}
canvas->resize(canvas->width(), h);
//resize(width(), h + title->height() + 5);
if(canvasview->document()) canvasview->document()->setModified(TRUE);
adjustSize();
QWidget * w = parentWidget();
if(w)
{
w->adjustSize();
if(w->isA("ReportSectionDetail"))
w->parentWidget()->adjustSize();
}
}
示例5: updateSize
void ItemWidget::updateSize(const QSize &maximumSize)
{
QWidget *w = widget();
w->setMinimumSize(0, 0);
w->setMaximumSize(maximumSize);
w->adjustSize();
w->setFixedSize( w->size() );
}
示例6: onCurrentChanged
void EditableLabelWidget::onCurrentChanged(int index)
{
QWidget* w = widget(index);
if (w == label) {
lineEdit->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
} else {
label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
}
w->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
w->adjustSize();
adjustSize();
}
示例7: sl_updateSizes
void DNAFlexDialog::sl_updateSizes(int index) {
Q_UNUSED(index);
for (int i=0; i < tabWidget->count(); i++) {
tabWidget->widget(i)->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
}
QWidget *widget = tabWidget->currentWidget();
widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
widget->resize(widget->minimumSizeHint());
widget->adjustSize();
tabWidget->resize(tabWidget->minimumSizeHint());
tabWidget->adjustSize();
}
示例8: toggleShowHide
void MainWindow::toggleShowHide()
{
if(ui->tab_widget_->isHidden()) {
ui->tab_widget_->show();
ui->show_hide_->setText("Hide");
} else {
ui->tab_widget_->hide();
ui->show_hide_->setText("Show");
}
QWidget *parent = ui->tab_widget_->parentWidget();
while(parent) {
parent->adjustSize();
parent = parent->parentWidget();
}
}
示例9: fillView
void QuizGroupView::fillView()
{
QuizGroup *g = (QuizGroup *)node();
ui->table->setColumnCount(1);
ui->table->setRowCount(g->children().count());
for(int i=0; i<g->children().count(); ++i)
{
QWidget *widget = cell(g->children()[i]);
widget->adjustSize();
if (widget->width()>ui->table->columnWidth(0))
ui->table->setColumnWidth(0, widget->width());
ui->table->setRowHeight(i, widget->height());
ui->table->setItem(i,0, new QTableWidgetItem());
ui->table->setCellWidget(i, 0, widget);
}
}
示例10: QWidget
PluginCfg::PluginCfg(QWidget *parent, const QString& pluginname) : QWidget(parent)
{
setupUi(this);
m_pluginName = pluginname;
if(ProfileManager::instance()->currentProfile()->enabledPlugins().contains(m_pluginName) ||
getPluginManager()->isPluginAlwaysEnabled(m_pluginName))
{
PluginPtr plugin = getPluginManager()->plugin(pluginname);
QWidget *w = plugin->createConfigWindow(addWnd);
if (w){
QVBoxLayout *lay = new QVBoxLayout(addWnd);
lay->addWidget(w);
QObject::connect(parent->topLevelWidget(), SIGNAL(applyChanges()), w, SLOT(apply()));
// adjust plugin widget
w->setMinimumSize(w->sizeHint());
w->adjustSize();
// adjust addWnd widget
addWnd->setMinimumSize(addWnd->sizeHint());
addWnd->adjustSize();
}
}
// adjust description
if(!getPluginManager()->pluginDescription(pluginname).isNull())
{
lblDescription->setText(i18n(getPluginManager()->pluginDescription(pluginname)));
}
else
{
lblDescription->setText("");
}
// adjust tab
tabWnd->setCurrentIndex(0);
tabWnd->setTabText(0, i18n(getPluginManager()->pluginTitle(pluginname)));
tabWnd->setMinimumSize(tabWnd->sizeHint());
tabWnd->adjustSize();
// adjust complete widget
setMinimumSize(sizeHint());
adjustSize();
if (getPluginManager()->isPluginAlwaysEnabled(pluginname)) {
chkEnable->hide();
} else {
chkEnable->setEnabled(true);
chkEnable->setChecked(ProfileManager::instance()->currentProfile()->enabledPlugins().contains(pluginname));
}
}
示例11: testRetainSizeWhenHidden
void tst_QLayout::testRetainSizeWhenHidden()
{
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
QSKIP("Test does not work on platforms which default to showMaximized()");
#endif
QWidget widget;
QBoxLayout layout(QBoxLayout::TopToBottom, &widget);
QLabel *label1 = new QLabel("label1 text", &widget);
layout.addWidget(label1);
QLabel *label2 = new QLabel("label2 text", &widget);
layout.addWidget(label2);
widget.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
int normalHeight = widget.height();
// a. Verify that a removed visible will mean lesser size after adjust
label1->hide();
widget.adjustSize();
int heightWithoutLabel1 = widget.height();
QVERIFY(heightWithoutLabel1 < normalHeight);
// b restore with verify that the size is the same
label1->show();
QCOMPARE(widget.sizeHint().height(), normalHeight);
// c verify that a policy with retainSizeWhenHidden is respected
QSizePolicy sp_remove = label1->sizePolicy();
QSizePolicy sp_retain = label1->sizePolicy();
sp_retain.setRetainSizeWhenHidden(true);
label1->setSizePolicy(sp_retain);
label1->hide();
QCOMPARE(widget.sizeHint().height(), normalHeight);
// d check that changing the policy to not wanting size will result in lesser size
label1->setSizePolicy(sp_remove);
QCOMPARE(widget.sizeHint().height(), heightWithoutLabel1);
// e verify that changing back the hidden widget to want the hidden size will ensure that it gets more size
label1->setSizePolicy(sp_retain);
QCOMPARE(widget.sizeHint().height(), normalHeight);
}
示例12: PluginCfgBase
PluginCfg::PluginCfg(QWidget *parent, pluginInfo *info)
: PluginCfgBase(parent)
{
m_info = info;
if (m_info->plugin){
QWidget *w = m_info->plugin->createConfigWindow(addWnd);
if (w){
QVBoxLayout *lay = new QVBoxLayout(addWnd);
lay->addWidget(w);
QObject::connect(parent->topLevelWidget(), SIGNAL(applyChanges()), w, SLOT(apply()));
// adjust plugin widget
w->setMinimumSize(w->sizeHint());
w->adjustSize();
// adjust addWnd widget
addWnd->setMinimumSize(addWnd->sizeHint());
addWnd->adjustSize();
}
}
// adjust description
if (m_info->info && m_info->info->description){
lblDescription->setText(i18n(m_info->info->description));
}else{
lblDescription->setText("");
}
// adjust tab
tabWnd->setCurrentPage(0);
tabWnd->changeTab(tabWnd->currentPage(), i18n(m_info->info->title));
tabWnd->setMinimumSize(tabWnd->sizeHint());
tabWnd->adjustSize();
// adjust complete widget
setMinimumSize(sizeHint());
adjustSize();
if (m_info->info && (m_info->info->flags & PLUGIN_NODISABLE)){
chkEnable->hide();
}else{
if (m_info->bNoCreate){
chkEnable->setEnabled(false);
chkEnable->setChecked(false);
}else{
chkEnable->setEnabled(true);
chkEnable->setChecked(!m_info->bDisabled);
}
}
}
示例13: init
CropImgScreen::CropImgScreen(QSize size, double scale, QString imgSrc, QString fileNameForSave, QWidget *parent):Overlay(parent)
{
init();
this->fileNameForSave = fileNameForSave;
scaleFactor = scale;
screenSize = size;
setMinimumSize(size);
setMaximumSize(size);
sideOff = sideOff*scale;
iconSize = iconSize*scale;
frameWidth = frameWidth*scale;
layout = new QVBoxLayout();
layout->setSpacing(0);
setLayout(layout);
layout->setContentsMargins(0,0,0,0);
imgIcon = new Cropper(scaleFactor,0,imgSrc,size-QSize(2*sideOff,0),false,this);
int topOffset = (size.height()-imgIcon->height())/2;
layout->addSpacing(topOffset);
layout->addWidget(imgIcon);
imgIcon->setAlignment(Qt::AlignCenter);
layout->addStretch(1);
QWidget *lineWidget = new QWidget(this);
QHBoxLayout *lineLayout = new QHBoxLayout(lineWidget);
lineWidget->setLayout(lineLayout);
lineLayout->setContentsMargins(0,0,0,0);
lineLayout->addStretch(1);
iconOk = new SimpleIcon(0,":/svg/tools/OKcamera.svg","",iconSize);
connect(iconOk,SIGNAL(click(int)),this,SLOT(onIconPressed(int)));
iconOk->setAlignment(Qt::AlignBottom|Qt::AlignRight);
lineLayout->addWidget(iconOk);
iconNo = new SimpleIcon(1,":/svg/tools/NOcamera.svg","",iconSize);
connect(iconNo,SIGNAL(click(int)),this,SLOT(onIconPressed(int)));
iconNo->setAlignment(Qt::AlignBottom|Qt::AlignRight);
lineLayout->addWidget(iconNo);
lineLayout->addStretch(1);
layout->addWidget(lineWidget);
layout->addSpacing(10*scaleFactor);
lineWidget->adjustSize();
}
示例14: setSize
void JabberSearch::setSize()
{
if (!m_bDirty || (parent() == NULL))
return;
m_bDirty = false;
for (QWidget *p = this; p; p = p->parentWidget()){
QSize s = p->sizeHint();
QSize s1 = QSize(p->width(), p->height());
p->setMinimumSize(s);
p->resize(QMAX(s.width(), s1.width()), QMAX(s.height(), s1.height()));
if (p->layout())
p->layout()->invalidate();
if (p == topLevelWidget())
break;
}
QWidget *t = topLevelWidget();
QSize s = t->sizeHint();
t->resize(QMAX(t->width(), s.width()), QMAX(t->height(), s.height()));
t->adjustSize();
}
示例15: adjustSizeShouldMakeSureLayoutIsActivated
void tst_QLayout::adjustSizeShouldMakeSureLayoutIsActivated()
{
QWidget main;
QVBoxLayout *const layout = new QVBoxLayout(&main);
layout->setMargin(0);
SizeHinterFrame *frame = new SizeHinterFrame(QSize(200, 10), QSize(200, 8));
frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
layout->addWidget(frame);
SizeHinterFrame *frame2 = new SizeHinterFrame(QSize(200, 10), QSize(200, 8));
frame2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
layout->addWidget(frame2);
main.show();
frame2->hide();
main.adjustSize();
QCOMPARE(main.size(), QSize(200, 10));
}