本文整理汇总了C++中QWidget::height方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::height方法的具体用法?C++ QWidget::height怎么用?C++ QWidget::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool QChildWidget::eventFilter(QObject *o, QEvent *e)
{
if (e->type() == QEvent::Paint){
QWidget *w = static_cast<QWidget*>(o);
for (QWidget *p = parentWidget(); p; p = p->parentWidget()){
const QPixmap *bg = p->backgroundPixmap();
if (bg){
QPoint pos = w->mapToGlobal(QPoint(0, 0));
pos = p->mapFromGlobal(pos);
QRect rc(pos.x(), pos.y(), w->width(), w->height());
if (rc != rcChild){
rcChild = rc;
QPixmap new_bg(w->width(), w->height());
QPainter pp(&new_bg);
pp.drawTiledPixmap(0, 0, w->width(), w->height(), *bg, pos.x(), pos.y());
pp.end();
w->setBackgroundPixmap(new_bg);
}
if (w->backgroundPixmap()){
QPainter pp(w);
pp.drawPixmap(0, 0, *w->backgroundPixmap());
}
return true;
}
}
}
return false;
}
示例2: eventFilter
bool eventFilter(QObject *pO, QEvent *event)
{
if ( event->type() == QEvent::Paint) {
QWidget* pW = qobject_cast<QWidget*>(pO);
QColor backColor = NotificationServerSettings::instance()->value("notification_backgroundColor").value<QColor>();
float fOpacity = NotificationServerSettings::instance()->value("notification_opacity").value<float>();
QPainter painter ( pW );
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing);
// corners
const int kShadowCornerSize = scShadowSize + scRadiusSize;
painter.drawPixmap(0, 0, shadowsCorners.at(0));
painter.drawPixmap(pW->width() - kShadowCornerSize, 0, shadowsCorners.at(1));
painter.drawPixmap(pW->width() - kShadowCornerSize, pW->height() - kShadowCornerSize, shadowsCorners.at(2));
painter.drawPixmap(0, pW->height() - kShadowCornerSize, shadowsCorners.at(3));
//edges
painter.drawTiledPixmap(kShadowCornerSize, 0,pW->width() - kShadowCornerSize*2, scShadowSize,shadowsEdges.at(0));
painter.drawTiledPixmap(pW->width() - scShadowSize, kShadowCornerSize,scShadowSize, pW->height() - kShadowCornerSize*2,shadowsEdges.at(1));
painter.drawTiledPixmap(kShadowCornerSize, pW->height() - scShadowSize,pW->width() - kShadowCornerSize*2, scShadowSize,shadowsEdges.at(2));
painter.drawTiledPixmap(0, kShadowCornerSize,scShadowSize, pW->height() - kShadowCornerSize*2,shadowsEdges.at(3));
// rounded pixmap
painter.setBrush(backColor);
painter.setPen(backColor);
painter.setOpacity(fOpacity);
painter.drawRoundedRect(scShadowSize,scShadowSize,pW->width()-2*scShadowSize, pW->height()-2*scShadowSize,scRadiusSize,scRadiusSize);
}
}
示例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: eventFilter
bool QChildWidget::eventFilter(QObject *o, QEvent *e)
{
if (e->type() == QEvent::Paint){
QWidget *w = static_cast<QWidget*>(o);
for (QWidget *p = parentWidget(); p; p = p->parentWidget()){
const QPixmap bg = p->palette().brush(p->backgroundRole()).texture();
if (!bg.isNull()){
QPoint pos = w->mapToGlobal(QPoint(0, 0));
pos = p->mapFromGlobal(pos);
QRect rc(pos.x(), pos.y(), w->width(), w->height());
if (rc != rcChild){
rcChild = rc;
QPixmap new_bg(w->width(), w->height());
QPainter pp(&new_bg);
pp.drawTiledPixmap(0, 0, w->width(), w->height(), bg, pos.x(), pos.y());
pp.end();
QPalette palette = w->palette();
palette.setBrush(w->backgroundRole(), QBrush(new_bg));
w->setPalette(palette);
}
if (!w->palette().brush(w->backgroundRole()).texture().isNull()){
QPainter pp(w);
pp.drawPixmap(0, 0, w->palette().brush(w->backgroundRole()).texture());
}
return true;
}
}
}
return false;
}
示例5: resizeEvent
/*
* resizeEvent is to resize mainWindow and put search box to center
* */
void MainWindow::resizeEvent(QResizeEvent *event) {
QMainWindow::resizeEvent(event);
QWidget *central = centralWidget();
QWidget *layoutContainer = central->findChild<QWidget *>("layoutContainer");
layoutContainer->move(QPoint((central->width() - layoutContainer->width()) / 2,
(central->height() - layoutContainer->height()) / 2));
}
示例6: shown
void
AnimatedSplitter::show( int index, bool animate )
{
m_animateIndex = index;
QWidget* w = widget( index );
QSize size = w->sizeHint();
if ( w->height() == size.height() )
return;
emit shown( w );
w->setMaximumHeight( QWIDGETSIZE_MAX );
qDebug() << "animating to:" << size.height() << "from" << w->height();
m_animateForward = true;
if ( animate )
{
if ( m_timeLine->state() == QTimeLine::Running )
m_timeLine->stop();
m_timeLine->setFrameRange( w->height(), size.height() );
m_timeLine->setDirection( QTimeLine::Forward );
m_timeLine->start();
}
else
{
onAnimationStep( size.height() );
onAnimationFinished();
}
}
示例7: hidden
void
AnimatedSplitter::hide( int index, bool animate )
{
m_animateIndex = index;
QWidget* w = widget( index );
int minHeight = m_sizes.at( index ).height();
if ( w->height() == minHeight )
return;
emit hidden( w );
w->setMinimumHeight( minHeight );
qDebug() << "animating to:" << w->height() << "from" << minHeight;
m_animateForward = false;
if ( animate )
{
if ( m_timeLine->state() == QTimeLine::Running )
m_timeLine->stop();
m_timeLine->setFrameRange( minHeight, w->height() );
m_timeLine->setDirection( QTimeLine::Backward );
m_timeLine->start();
}
else
{
onAnimationStep( minHeight );
onAnimationFinished();
}
}
示例8: updateGeometry
void NewsDetailViewModule::updateGeometry() {
QWidget *playlistRegion = _shell->findRegion( "PlaylistRegion" )->widget();
if( playlistRegion != NULL ) {
int width = _fixedWidth;
int height = _fixedHeight;
int widthProportional = ( int ) playlistRegion->width() * Constants::NEWSDETAILVIEW_WIDTH_PROCENT_PLAYLISTREGION / 100;
int heightProportional = ( int ) playlistRegion->height() * Constants::NEWSDETAILVIEW_HEIGHT_PROCENT_PLAYLISTREGION / 100;
if( width < widthProportional )
width = widthProportional;
else if( width > playlistRegion->width() )
width = playlistRegion->width();
if( height < heightProportional )
height = heightProportional;
else if( height > playlistRegion->height() )
height = playlistRegion->height();
int left = ( playlistRegion->x() + playlistRegion->width() / 2 ) - ( width / 2 );
int top = playlistRegion->y();
_region->widget()->move( left, top );
_region->widget()->resize( width, height );
}
}
示例9: mouseMoveEvent
/*!
Resizes the top-level widget containing this widget. The event is
in \a e.
*/
void QSizeGrip::mouseMoveEvent( QMouseEvent * e )
{
if ( e->state() != LeftButton )
return;
QWidget* tlw = qt_sizegrip_topLevelWidget(this);
if ( tlw->testWState(WState_ConfigPending) )
return;
QPoint np( e->globalPos() );
QWidget* ws = qt_sizegrip_workspace( this );
if ( ws ) {
QPoint tmp( ws->mapFromGlobal( np ) );
if ( tmp.x() > ws->width() )
tmp.setX( ws->width() );
if ( tmp.y() > ws->height() )
tmp.setY( ws->height() );
np = ws->mapToGlobal( tmp );
}
int w;
int h = np.y() - p.y() + s.height();
if ( QApplication::reverseLayout() )
w = s.width() - ( np.x() - p.x() );
else
w = np.x() - p.x() + s.width();
if ( w < 1 )
w = 1;
if ( h < 1 )
h = 1;
QSize ms( tlw->minimumSizeHint() );
ms = ms.expandedTo( minimumSize() );
if ( w < ms.width() )
w = ms.width();
if ( h < ms.height() )
h = ms.height();
if (QApplication::reverseLayout()) {
tlw->resize( w, h );
if (tlw->size() == QSize(w,h))
tlw->move( tlw->x() + ( np.x()-p.x() ), tlw->y() );
} else {
tlw->resize( w, h );
}
#ifdef Q_WS_WIN
MSG msg;
while( PeekMessage( &msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE ) )
;
#endif
QApplication::syncX();
if ( QApplication::reverseLayout() && tlw->size() == QSize(w,h) ) {
s.rwidth() = tlw->size().width();
p.rx() = np.x();
}
}
示例10: getFixedSize
void NewsDetailViewModule::getFixedSize() {
QSize minScreenSize = getSmallestMonitorScreenSize();
_fixedWidth = ( int ) minScreenSize.width() * Constants::NEWSDETAILVIEW_WIDTH_PROCENT_PLAYLISTREGION / 100;
QWidget *topRegion = _shell->findRegion( "TopRegion" )->widget();
QWidget *searchRegion = _shell->findRegion( "SearchRegion" )->widget();
_fixedHeight = ( int )( minScreenSize.height() - topRegion->height() - searchRegion->height() - topRegion->height() )
* Constants::NEWSDETAILVIEW_HEIGHT_PROCENT_PLAYLISTREGION / 100;
}
示例11: resize_container
static void resize_container(void *_object, QWidget *cont, int w, int h)
{
QWidget *wid = ((CWIDGET *)_object)->widget;
#if USE_CACHE
resize_widget(_object, w + wid->width() - cont->width(), h + wid->height() - cont->height());
#else
CWIDGET_resize(_object, w + wid->width() - cont->width(), h + wid->height() - cont->height());
#endif
}
示例12: resize
void AssureView::resize()
{
QWidget *wParent = dynamic_cast<QWidget *>(parent());
if (wParent) {
setFixedHeight(wParent->height()*0.7);
move((wParent->width() - width())/2, (wParent->height() - height())/2);
}
m_vbox->setAlignment(m_assure, Qt::AlignHCenter);
m_hbox->setSpacing(m_assure->width() - 2*m_yesBtn->width());
}
示例13: doResize
void MainWindow::doResize()
{
QWidget *w = centralWidget();
if (w->layout()==0) return;
if (w->width() > w->height()) {
w->setContentsMargins((w->width()-w->height())/2,0,
(w->width()-w->height())/2,0);
} else {
w->setContentsMargins(0,(w->height()-w->width())/2,
0,(w->height()-w->width())/2);
}
}
示例14: dropEvent
void LXQtGroupPopup::dropEvent(QDropEvent *event)
{
qlonglong temp;
QDataStream stream(event->mimeData()->data(LXQtTaskButton::mimeDataFormat()));
stream >> temp;
WId window = (WId) temp;
LXQtTaskButton *button = nullptr;
int oldIndex(0);
// get current position of the button being dragged
for (int i = 0; i < layout()->count(); i++)
{
LXQtTaskButton *b = qobject_cast<LXQtTaskButton*>(layout()->itemAt(i)->widget());
if (b && b->windowId() == window)
{
button = b;
oldIndex = i;
break;
}
}
if (button == nullptr)
return;
int newIndex = -1;
// find the new position to place it in
for (int i = 0; i < oldIndex && newIndex == -1; i++)
{
QWidget *w = layout()->itemAt(i)->widget();
if (w && w->pos().y() + w->height() / 2 > event->pos().y())
newIndex = i;
}
const int size = layout()->count();
for (int i = size - 1; i > oldIndex && newIndex == -1; i--)
{
QWidget *w = layout()->itemAt(i)->widget();
if (w && w->pos().y() + w->height() / 2 < event->pos().y())
newIndex = i;
}
if (newIndex == -1 || newIndex == oldIndex)
return;
QVBoxLayout * l = qobject_cast<QVBoxLayout *>(layout());
l->takeAt(oldIndex);
l->insertWidget(newIndex, button);
l->invalidate();
}
示例15: layout
ZLQtWaitMessage::ZLQtWaitMessage(const std::string &message) : QWidget(0, 0, WType_Popup) {
resize(1, 1);
QHBoxLayout layout(this, 24);
QLabel *label = new QLabel(::qtString(message), this);
layout.add(label);
qApp->processEvents();
QWidget *root = QApplication::desktop();
move(root->width() / 2 - width() / 2, root->height() / 2 - height() / 2);
show();
move(root->width() / 2 - width() / 2, root->height() / 2 - height() / 2);
qApp->processEvents();
}