本文整理汇总了C++中QSizePolicy::setHeightForWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QSizePolicy::setHeightForWidth方法的具体用法?C++ QSizePolicy::setHeightForWidth怎么用?C++ QSizePolicy::setHeightForWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSizePolicy
的用法示例。
在下文中一共展示了QSizePolicy::setHeightForWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: myPalette
ChatWidget::ChatWidget(QWidget *parent) : QScrollArea(parent), ui(new Ui::ChatWidget) {
ui->setupUi(this);
this->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOn);
this->setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded);
QSizePolicy selfSizePolicy = this->sizePolicy();
selfSizePolicy.setHeightForWidth(true);
this->setSizePolicy(selfSizePolicy);
this->setWidgetResizable(true);
QSizePolicy contentsSizePolicy = ui->scrollAreaWidgetContents->sizePolicy();
contentsSizePolicy.setHorizontalPolicy(QSizePolicy::Expanding);
contentsSizePolicy.setVerticalPolicy(QSizePolicy::Expanding);
contentsSizePolicy.setHeightForWidth(true);
ui->scrollAreaWidgetContents->setSizePolicy(contentsSizePolicy);
ui->scrollAreaWidgetContents->setMinimumWidth(400);
this->setWidget(ui->scrollAreaWidgetContents);
topLayout = new QVBoxLayout();
ui->scrollAreaWidgetContents->setLayout(topLayout);
QPalette myPalette(palette());
myPalette.setColor(QPalette::Background, Qt::white);
this->setAutoFillBackground(true);
this->setPalette(myPalette);
}
示例2: sizeof
EmulLCD::EmulLCD(QWidget *parent) :
QFrame(parent),
fg_color(LCD_FG_COLOR),
bg_brush(QColor(LCD_BG_COLOR))
{
// Optimized rendering: we repaint everything anyway
setAttribute(Qt::WA_NoSystemBackground);
// initialize bitmap
memset(raster, 0xAA, sizeof(raster));
// set widget frame
setFrameStyle(QFrame::Panel | QFrame::Sunken);
frame_width = frameWidth();
setMinimumSize(WIDTH + frame_width * 2, HEIGHT + frame_width * 2);
#if CONFIG_EMULLCD_SCALE
QSizePolicy pol = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred, QSizePolicy::Frame);
pol.setHeightForWidth(true);
#else
QSizePolicy pol = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed, QSizePolicy::Frame);
#endif
setSizePolicy(pol);
}
示例3: sizePolicy
VBoxSettingsTreeViewSelector::VBoxSettingsTreeViewSelector (QWidget *aParent /* = NULL */)
:VBoxSettingsSelector (aParent)
{
mTwSelector = new QITreeWidget (aParent);
/* Configure the selector */
QSizePolicy sizePolicy (QSizePolicy::Minimum, QSizePolicy::Expanding);
sizePolicy.setHorizontalStretch (0);
sizePolicy.setVerticalStretch (0);
sizePolicy.setHeightForWidth (mTwSelector->sizePolicy().hasHeightForWidth());
const QStyle *pStyle = QApplication::style();
const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize);
mTwSelector->setSizePolicy (sizePolicy);
mTwSelector->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
mTwSelector->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
mTwSelector->setRootIsDecorated (false);
mTwSelector->setUniformRowHeights (true);
mTwSelector->setIconSize(QSize((int)(1.5 * iIconMetric), (int)(1.5 * iIconMetric)));
/* Add the columns */
mTwSelector->headerItem()->setText (treeWidget_Category, "Category");
mTwSelector->headerItem()->setText (treeWidget_Id, "[id]");
mTwSelector->headerItem()->setText (treeWidget_Link, "[link]");
/* Hide unnecessary columns and header */
mTwSelector->header()->hide();
mTwSelector->hideColumn (treeWidget_Id);
mTwSelector->hideColumn (treeWidget_Link);
/* Setup connections */
connect (mTwSelector, SIGNAL (currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)),
this, SLOT (settingsGroupChanged (QTreeWidgetItem *, QTreeWidgetItem*)));
}
示例4: sizePolicy
FlowLayout::FlowLayout()
{
m_spacing[0] = 6;
m_spacing[1] = 6;
QSizePolicy sp = sizePolicy();
sp.setHeightForWidth(true);
setSizePolicy(sp);
}
示例5: QWidget
HFWWidget::HFWWidget()
: QWidget()
{
setMinimumSize(QSize(100,50));
QSizePolicy s = sizePolicy();
s.setHeightForWidth(true);
setSizePolicy(s);
}
示例6:
QtMeasuringEditorDialogue::QtMeasuringEditorDialogue(QWidget * parent, const char * name, bool modal, Qt::WFlags f, QString appPath)
:Q3TabDialog(parent, name, modal,f)
{
apppath = appPath;
QSizePolicy sizepolicy;
sizepolicy.setHeightForWidth(TRUE);
setSizePolicy(sizepolicy);
setCaption("Measuring Editor");
//setIcon( QPixmap( "Icons/ruler.png" ));
build_layout();
}
示例7: ChatWidgetItem
TextChatWidgetItem::TextChatWidgetItem(Contact* contact, ContactIdWithMessageId const& senderAndMessageId, QString const& message, QWidget *parent) : ChatWidgetItem(contact, senderAndMessageId, parent), ui(new Ui::TextChatWidgetItem), message(message) {
ui->setupUi(this);
QSizePolicy sp = this->sizePolicy();
sp.setHeightForWidth(true);
this->setSizePolicy(sp);
ui->lblMessageText->setText(preprocessLinks(message));
ui->lblMessageText->setWordWrap(true);
ui->lblFromTime->setWordWrap(true);
onDataUpdated();
}
示例8: ChatWidgetItem
LocationChatWidgetItem::LocationChatWidgetItem(Contact* contact, ContactIdWithMessageId const& senderAndMessageId, QDateTime const& timeSend, QDateTime const& timeReceived, double latitude, double longitude, double height, QString const& description, QWidget *parent) : ChatWidgetItem(contact, senderAndMessageId, timeSend, timeReceived, parent), ui(new Ui::LocationChatWidgetItem), latitude(latitude), longitude(longitude), height(height), description(description) {
ui->setupUi(this);
QSizePolicy sp = this->sizePolicy();
sp.setHeightForWidth(true);
this->setSizePolicy(sp);
QString const locationUrl = QString(QStringLiteral("https://maps.google.com/?q=%1,%2")).arg(latitude).arg(longitude);
ui->lblMessageText->setText(QString("Location: <a href=\"%1\">%1</a> - %2").arg(locationUrl).arg(description));
ui->lblMessageText->setWordWrap(true);
ui->lblFromTime->setWordWrap(true);
onDataUpdated();
}
示例9: QWidget
MiniMap::MiniMap(const QPixmap& overview, QWidget *parent)
: QWidget(parent),
_overview(overview),
_fieldOfView(QRectF()),
_aspectRatio(1),
_manager(NULL),
_drawCoverageMap(true)
{
QSizePolicy policy;
policy.setHeightForWidth(true);
policy.setHorizontalPolicy(QSizePolicy::Fixed);
policy.setVerticalPolicy(QSizePolicy::Fixed);
setSizePolicy(policy);
if (!overview.isNull()) {
_aspectRatio = static_cast<float>(_overview.width()) / _overview.height();
}
}
示例10: setWordWrap
void DNotificationWidget::setWordWrap(bool wordWrap)
{
d->wordWrap = wordWrap;
d->textLabel->setWordWrap(wordWrap);
QSizePolicy policy = sizePolicy();
policy.setHeightForWidth(wordWrap);
setSizePolicy(policy);
d->updateLayout();
// Without this, when user does wordWrap -> !wordWrap -> wordWrap, a minimum
// height is set, causing the widget to be too high.
// Mostly visible in test programs.
if (wordWrap)
{
setMinimumHeight(0);
}
}
示例11: heightForWidth
void tst_QGraphicsLinearLayout::heightForWidth()
{
QFETCH(bool, hfw);
QFETCH(bool, nested);
QGraphicsScene scene;
QGraphicsWidget *form = new QGraphicsWidget;
scene.addItem(form);
QGraphicsLinearLayout *outerlayout = 0;
if (nested) {
outerlayout = new QGraphicsLinearLayout(form);
for (int i = 0; i < 8; i++) {
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
outerlayout->addItem(layout);
outerlayout = layout;
}
}
QGraphicsLinearLayout *qlayout = 0;
qlayout = new QGraphicsLinearLayout(Qt::Vertical);
if (nested)
outerlayout->addItem(qlayout);
else
form->setLayout(qlayout);
MySquareWidget *widget = new MySquareWidget;
for (int i = 0; i < 1; i++) {
widget = new MySquareWidget;
QSizePolicy sizepolicy = widget->sizePolicy();
sizepolicy.setHeightForWidth(hfw);
widget->setSizePolicy(sizepolicy);
qlayout->addItem(widget);
}
// make sure only one iteration is done.
// run with tst_QGraphicsLinearLayout.exe "heightForWidth" -tickcounter -iterations 6
// this will iterate 6 times the whole test, (not only the benchmark)
// which should reduce warmup time and give a realistic picture of the performance of
// effectiveSizeHint()
QSizeF constraint(hfw ? 100 : -1, -1);
QBENCHMARK {
(void)form->effectiveSizeHint(Qt::PreferredSize, constraint);
}
}
示例12: QWidget
VideoWidget::VideoWidget(MainWindow *main) : QWidget((QWidget *)main)
{
m_main = main;
m_xOffset=0;
m_yOffset=0;
m_background = NULL;
m_scale = 1.0;
m_drag = false;
m_selection = false;
m_pm = new QPixmap;
// set size policy--- preferred aspect ratio
QSizePolicy policy = sizePolicy();
policy.setHeightForWidth(true);
setSizePolicy(policy);
setMouseTracking(true);
}
示例13: setAttribute
QSFMLCanvas::QSFMLCanvas(QWidget* Parent) :
QWidget (Parent),
myInitialized (false),
paintCount (0)
{
// Setup some states to allow direct rendering into the widget
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_OpaquePaintEvent);
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_PaintUnclipped);
// Set strong focus to enable keyboard events to be received
setFocusPolicy(Qt::WheelFocus);
QSizePolicy test = this->sizePolicy();// (QSizePolicy::Minimum, QSizePolicy::Minimum);
test.setHeightForWidth(true);
setSizePolicy(test);
}
示例14: QWidget
VideoWidget::VideoWidget(MainWindow *main) : QWidget((QWidget *)main), m_mutex(QMutex::Recursive)
{
qRegisterMetaType<VideoWidget::InputMode>("VideoWidget::InputMode");
m_main = main;
m_xOffset=0;
m_yOffset=0;
m_scale = 1.0;
m_drag = false;
m_inputMode = NONE;
m_selection = false;
// set size policy--- preferred aspect ratio
QSizePolicy policy = sizePolicy();
policy.setHeightForWidth(true);
setSizePolicy(policy);
setMouseTracking(true);
}
示例15: QgsMapCanvas
ImageCanvas::ImageCanvas(DatabaseHandler * db, QWidget * parent) : QgsMapCanvas(parent), parent(parent), db(db) {
// sizePolicy().setHeightForWidth(true);
QSizePolicy policy;
policy.setHorizontalPolicy(QSizePolicy::Expanding);
policy.setVerticalPolicy(QSizePolicy::Preferred);
policy.setHeightForWidth(true);
setSizePolicy(policy);
setBaseSize(240,240);
enableAntiAliasing(true);
setParallelRenderingEnabled( true );
setCanvasColor(QColor(0, 0, 0));
freeze(false);
setCachingEnabled(true);
setCacheMode(QgsMapCanvas::CacheBackground);
setMapUnits(QGis::Meters);
provider_registry = QgsProviderRegistry::instance();
layer_registry = QgsMapLayerRegistry::instance();
}