/*! 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(); } }
// size hint according to content QSize QgsIdentifyResultsWebView::sizeHint() const { QSize s = page()->mainFrame()->contentsSize(); QgsDebugMsg( QString( "content size: %1 x %2" ).arg( s.width() ).arg( s.height() ) ); int height = s.height(); // parent is qt_scrollarea_viewport // parent is not available the first time - before results dialog was shown QWidget *widget = qobject_cast<QWidget *>( parent() ); if ( widget ) { // It can probably happen that parent is available but it does not have yet // correct size, see #9377. int max = widget->size().height() * 0.9; QgsDebugMsg( QString( "parent widget height = %1 max height = %2" ).arg( widget->size().height() ).arg( max ) ); height = qMin( height, max ); } else { QgsDebugMsg( "parent not available" ) ; } // Always keep some minimum size, e.g. if page is not yet loaded // or parent has wrong size height = qMax( height, 100 ); s = QSize( size().width(), height ); QgsDebugMsg( QString( "size: %1 x %2" ).arg( s.width() ).arg( s.height() ) ); return s; }
// size hint according to content QSize QgsIdentifyResultsWebView::sizeHint() const { QSize s = page()->mainFrame()->contentsSize(); QgsDebugMsg( QString( "content size: %1 x %2" ).arg( s.width() ).arg( s.height() ) ); int height = s.height(); // if page is not yet loaded set some minimum height if ( height == 0 ) { height = 100; } else { // parent is qt_scrollarea_viewport // parent is not available the first time - before results dialog was shown QWidget *widget = qobject_cast<QWidget *>( parent() ); if ( widget ) { int max = widget->size().height() * 0.9; QgsDebugMsg( QString( "parent widget height = %1 max height = %2" ).arg( widget->size().height() ).arg( max ) ); if ( height > max ) height = max; } else { QgsDebugMsg( "parent not available" ) ; } } s = QSize( size().width(), height ); QgsDebugMsg( QString( "size: %1 x %2" ).arg( s.width() ).arg( s.height() ) ); return s; }
void QwtPicker::updateDisplay() { QWidget *w = parentWidget(); bool showRubberband = false; bool showTracker = false; if ( w && w->isVisible() && d_data->enabled ) { if ( rubberBand() != NoRubberBand && isActive() && rubberBandPen().style() != Qt::NoPen ) { showRubberband = true; } if ( trackerMode() == AlwaysOn || (trackerMode() == ActiveOnly && isActive() ) ) { if ( trackerPen() != Qt::NoPen ) showTracker = true; } } #if QT_VERSION < 0x040000 QGuardedPtr<PrivateData::PickerWidget> &rw = d_data->rubberBandWidget; #else QPointer<PrivateData::PickerWidget> &rw = d_data->rubberBandWidget; #endif if ( showRubberband ) { if ( rw.isNull() ) { rw = new PrivateData::PickerWidget( this, w, PrivateData::PickerWidget::RubberBand); rw->resize(w->size()); } rw->updateMask(); } else delete rw; #if QT_VERSION < 0x040000 QGuardedPtr<PrivateData::PickerWidget> &tw = d_data->textLabelWidget; #else QPointer<PrivateData::PickerWidget> &tw = d_data->textLabelWidget; #endif if ( showTracker ) { if ( tw.isNull() ) { tw = new PrivateData::PickerWidget( this, w, PrivateData::PickerWidget::Text); tw->resize(w->size()); } tw->updateMask(); } else delete tw; }
//! Update the state of rubberband and tracker label void QwtPicker::updateDisplay() { QWidget *w = parentWidget(); bool showRubberband = false; bool showTracker = false; if ( w && w->isVisible() && d_data->enabled ) { if ( rubberBand() != NoRubberBand && isActive() && rubberBandPen().style() != Qt::NoPen ) { showRubberband = true; } if ( trackerMode() == AlwaysOn || ( trackerMode() == ActiveOnly && isActive() ) ) { if ( trackerPen() != Qt::NoPen ) showTracker = true; } } QPointer<PickerWidget> &rw = d_data->rubberBandWidget; if ( showRubberband ) { if ( rw.isNull() ) { rw = new PickerWidget( this, w, PickerWidget::RubberBand ); rw->setObjectName( "PickerRubberBand" ); rw->resize( w->size() ); } rw->updateMask(); rw->update(); // Needed, when the mask doesn't change } else delete rw; QPointer<PickerWidget> &tw = d_data->trackerWidget; if ( showTracker ) { if ( tw.isNull() ) { tw = new PickerWidget( this, w, PickerWidget::Text ); tw->setObjectName( "PickerTracker" ); tw->resize( w->size() ); } tw->setFont( d_data->trackerFont ); tw->updateMask(); tw->update(); // Needed, when the mask doesn't change } else delete tw; }
void Layout::breakLayout() { WidgetFactory::deleteLayout( layoutBase ); bool needReparent = qstrcmp( layoutBase->className(), "QLayoutWidget" ) == 0 || ( !WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( layoutBase ) ) ) && layoutBase != formWindow->mainContainer() ); bool add = geometries.isEmpty(); for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { if ( needReparent ) w->reparent( layoutBase->parentWidget(), 0, layoutBase->pos() + w->pos(), TRUE ); if ( add ) geometries.insert( w, QRect( w->pos(), w->size() ) ); } if ( needReparent ) { layoutBase->hide(); parent = layoutBase->parentWidget(); } else { parent = layoutBase; } if ( widgets.first() && widgets.first()->isVisibleTo( formWindow ) ) formWindow->selectWidget( widgets.first() ); else formWindow->selectWidget( formWindow ); }
RtpPlayerDialog::RtpPlayerDialog(QWidget &parent, CaptureFile &cf) : WiresharkDialog(parent, cf) #ifdef QT_MULTIMEDIA_LIB , ui(new Ui::RtpPlayerDialog) , start_rel_time_(0.0) #endif // QT_MULTIMEDIA_LIB { ui->setupUi(this); setWindowTitle(wsApp->windowTitleString(tr("RTP Player"))); resize(parent.size()); #ifdef QT_MULTIMEDIA_LIB ui->splitter->setStretchFactor(0, 3); ui->splitter->setStretchFactor(1, 1); ctx_menu_ = new QMenu(this); ctx_menu_->addAction(ui->actionZoomIn); ctx_menu_->addAction(ui->actionZoomOut); ctx_menu_->addAction(ui->actionReset); ctx_menu_->addSeparator(); ctx_menu_->addAction(ui->actionMoveRight10); ctx_menu_->addAction(ui->actionMoveLeft10); ctx_menu_->addAction(ui->actionMoveRight1); ctx_menu_->addAction(ui->actionMoveLeft1); ctx_menu_->addSeparator(); ctx_menu_->addAction(ui->actionGoToPacket); ctx_menu_->addSeparator(); ctx_menu_->addAction(ui->actionDragZoom); ctx_menu_->addAction(ui->actionToggleTimeOrigin); ctx_menu_->addAction(ui->actionCrosshairs); connect(ui->audioPlot, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*))); connect(ui->audioPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(graphClicked(QMouseEvent*))); cur_play_pos_ = new QCPItemStraightLine(ui->audioPlot); ui->audioPlot->addItem(cur_play_pos_); cur_play_pos_->setVisible(false); ui->audioPlot->xAxis->setNumberFormat("gb"); ui->audioPlot->xAxis->setNumberPrecision(3); ui->audioPlot->xAxis->setDateTimeFormat("yyyy-MM-dd\nhh:mm:ss.zzz"); ui->audioPlot->yAxis->setVisible(false); ui->playButton->setIcon(StockIcon("media-playback-start")); ui->stopButton->setIcon(StockIcon("media-playback-stop")); ui->audioPlot->setMouseTracking(true); ui->audioPlot->setEnabled(true); ui->audioPlot->setInteractions( QCP::iRangeDrag | QCP::iRangeZoom ); ui->audioPlot->setFocus(); QTimer::singleShot(0, this, SLOT(retapPackets())); #endif // QT_MULTIMEDIA_LIB }
int main(int argv, char **args) { QApplication app(argv, args); int n = 8; int size = 40; int bsize = (n*size - 5)/3 - 5; QPushButton *buttons[n][n]; QWidget window; window.setGeometry(300, 300, 10+size*n, 5+size*n + size + 10); window.setFixedSize(window.size()); for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { buttons[i][j] = new QPushButton("", &window); QObject::connect(buttons[i][j], SIGNAL(clicked()), qApp, SLOT(quit())); buttons[i][j]->setGeometry(5+i*size, 5+j*size, size, size); } } QPushButton *newGameButton = new QPushButton("New Game", &window); newGameButton->setGeometry(5, n*size + 10, bsize, size); QPushButton *diffButton = new QPushButton("Difficulty", &window); diffButton->setGeometry(5 + 2*n*size/3 + 5, n*size + 10, bsize, size); window.show(); return app.exec(); }
void DesktopCaptureElement::srceenResized(int screen) { QString media = QString("screen://%1").arg(screen); QWidget *widget = QApplication::desktop()->screen(screen); emit this->sizeChanged(media, widget->size()); }
POCO_END_MANIFEST //API stuff here first //for javascript to load a .ui file and get the widget in return, to assign connections QScriptValue RexQtScript::LoadUI(QScriptContext *context, QScriptEngine *engine) { QWidget *widget; QScriptValue qswidget; boost::shared_ptr<QtUI::QtModule> qt_module = RexQtScript::staticframework->GetModuleManager()->GetModule<QtUI::QtModule>(Foundation::Module::MT_Gui).lock(); boost::shared_ptr<QtUI::UICanvas> canvas_; //if ( qt_module.get() == 0) // return NULL; canvas_ = qt_module->CreateCanvas(QtUI::UICanvas::External).lock(); QUiLoader loader; QFile file("../RexQtScriptModule/proto/dialog.ui"); widget = loader.load(&file); canvas_->AddWidget(widget); // Set canvas size. canvas_->resize(widget->size()); canvas_->Show(); qswidget = engine->newQObject(widget); return qswidget; }
MusicApplicationObject::MusicApplicationObject(QObject *parent) : QObject(parent), m_mobileDevices(nullptr) { m_supperClass = MStatic_cast(QWidget*, parent); QWidget *widget = QApplication::desktop(); m_supperClass->move( (widget->width() - m_supperClass->width())/2, (widget->height() - m_supperClass->height())/2 ); M_SETTING->setValue(MusicSettingManager::ScreenSize, widget->size()); windowStartAnimationOpacity(); m_musicTimerAutoObj = new MusicTimerAutoObject(this); connect(m_musicTimerAutoObj, SIGNAL(setPlaySong(int)), parent, SLOT(setPlaySongChanged(int))); connect(m_musicTimerAutoObj, SIGNAL(setStopSong()), parent, SLOT(setStopSongChanged())); #ifdef Q_OS_UNIX m_mobileDevicesLinux = new MusicMobileDevicesThread(this); connect(m_mobileDevicesLinux, SIGNAL(devicesChanged(bool)), SLOT(musicDevicesLinuxChanged(bool))); m_mobileDevicesLinux->start(); #elif defined Q_OS_WIN m_mobileDevicesLinux = nullptr; #endif m_setWindowToTop = false; M_CONNECTION->setValue("MusicApplicationObject", this); M_CONNECTION->poolConnect("MusicApplicationObject", "MusicApplication"); M_CONNECTION->poolConnect("MusicApplicationObject", "MusicEnhancedWidget"); musicToolSetsParameter(); }
void KexiAnimatedLayout::Private::animateTo(QWidget* destination) { QWidget *from = q->currentWidget(); Q_ASSERT(destination && from); destinationWidget = destination; if (from == destinationWidget) return; if (!(KexiUtils::graphicEffectsLevel() & KexiUtils::SimpleAnimationEffects)) { // animations not allowed: switch to destination widget immediately animationFinished(); return; } bool toRight = q->currentIndex() < q->indexOf(destinationWidget); hide(); setParent(from); QSize s(from->parentWidget()->size()); QPoint startPos(toRight ? QPoint(0, 0) : QPoint(s.width(), 0)); QPoint endPos(toRight ? QPoint(s.width(), 0) : QPoint(0, 0)); animation.setStartValue(-startPos); animation.setEndValue(-endPos); buffer = QPixmap(s.width() * 2, s.height()); buffer.fill(Qt::white); from->render(&buffer, startPos); //qDebug() << s << from->geometry() << destinationWidget->geometry(); destinationWidget->resize(from->size()); // needed because destination could // have been never displayed destinationWidget->render(&buffer, endPos); resize(buffer.size()); move(animation.startValue().toPoint().x(), animation.startValue().toPoint().y()); show(); animation.start(); }
//! Update the cached information about the current style sheet void QwtPlotAbstractCanvas::updateStyleSheetInfo() { QWidget *w = canvasWidget(); if ( !w->testAttribute( Qt::WA_StyledBackground ) ) return; QwtStyleSheetRecorder recorder( w->size() ); QPainter painter( &recorder ); QStyleOption opt; opt.initFrom(w); w->style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, w); painter.end(); d_data->styleSheet.hasBorder = !recorder.border.rectList.isEmpty(); d_data->styleSheet.cornerRects = recorder.clipRects; if ( recorder.background.path.isEmpty() ) { if ( !recorder.border.rectList.isEmpty() ) { d_data->styleSheet.borderPath = qwtCombinePathList( w->rect(), recorder.border.pathList ); } } else { d_data->styleSheet.borderPath = recorder.background.path; d_data->styleSheet.background.brush = recorder.background.brush; d_data->styleSheet.background.origin = recorder.background.origin; } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { /* Window Title */ setWindowTitle(tr(APPLICATION_NAME)); /* Set sticky places for dockwidgets */ setCorner(Qt::TopLeftCorner, Qt::TopDockWidgetArea); setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); setCorner(Qt::BottomLeftCorner, Qt::BottomDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); /* * Create Mastercontroller (zone -1) * Controls all zones on all bridges. */ master = new SingleController("Master", -1, this); masterDockWidget = new QDockWidget(tr("Master Controller"), this); masterDockWidget->setWidget(master); masterDockWidget->setMaximumWidth(200); addDockWidget(Qt::TopDockWidgetArea, masterDockWidget); /* Audio Controller */ audio = new audioController(this); addDockWidget(Qt::TopDockWidgetArea, audio); /* Connect Audio to Master .*/ connect(audio, SIGNAL(setRandomSame()), master, SLOT(setRandomExt())); connect(audio, SIGNAL(flash()), master, SLOT(flash())); connect(audio, SIGNAL(flashRandom()), master, SLOT(flashRandom())); connect(audio, SIGNAL(fade10()), master, SLOT(fade10Ext())); connect(audio, SIGNAL(fade20()), master, SLOT(fade20Ext())); presetController = new PresetController(this); presetController->setMinimumWidth(230); addDockWidget(Qt::TopDockWidgetArea, presetController); connect(presetController, SIGNAL(createPreset()), this, SLOT(getPreset())); connect(this, SIGNAL(presetAvailable(Preset*)), presetController, SLOT(addPreset(Preset*))); connect(presetController, SIGNAL(setPreset(Preset*)), this, SLOT(setPreset(Preset*))); /* Center the window. */ QWidget *w = window(); w->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, w->size(), qApp->desktop()->availableGeometry())); /* Create Bridge Discovery Dialog. */ MiLightDiscover *d = new MiLightDiscover(this); connect(d, SIGNAL(selectedDevices(QStringList, bool)), this, SLOT(setupControllers(QStringList, bool))); d->exec(); setupActions(); setupToolBar(); setupMenuBar(); setupStatusBar(); loadSettings(); delete d; }
bool eventFilter(QObject* obj, QEvent* event) override { // check input if (event->type() != QEvent::MouseButtonDblClick) return false; QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); if (mouseEvent->button() != Qt::LeftButton) return false; QSplitterHandle* splitterHandle = qobject_cast<QSplitterHandle*>(obj); if (!splitterHandle) return false; QSplitter* splitter = splitterHandle->splitter(); if (!splitter || splitter->count() < 2) return false; // change splitter sizes to make description panel occupy ideal height QWidget* bottomWidget = splitter->widget(1); QList<int> sizes = splitter->sizes(); if (sizes.size() != 2) return false; sizes[0] += sizes[1]; sizes[1] = bottomWidget->heightForWidth(bottomWidget->size().width()); sizes[0] -= qMax(sizes[1], 0); splitter->setSizes(sizes); return true; }
void ItemWidget::updateSize(const QSize &maximumSize) { QWidget *w = widget(); w->setMinimumSize(0, 0); w->setMaximumSize(maximumSize); w->adjustSize(); w->setFixedSize( w->size() ); }
QSize GetParentSize() { QWidget * parent = parentWidget(); if(parent) return parent->size(); else return QSize(); }
void tst_QWidget_window::tst_show_resize() { QWidget w; w.show(); w.resize(200, 200); QCOMPARE(w.size(), QSize(200, 200)); // QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); }
void TabSwitchWidget::generatePreview(int idx) { QWidget *w = tabWidget()->widget(idx); QPixmap pixmap(w->size()); w->render(&pixmap); pixmap = pixmap.scaled(ui->prevLabel->size(), Qt::KeepAspectRatio, sConfig.get(CFG_BOOL_SMOOTH_SCALING) ? Qt::SmoothTransformation : Qt::FastTransformation); ui->prevLabel->setPixmap(pixmap); }
void DefaultGui::adjustFloatingControlSize() { qDebug("DefaultGui::adjustFloatingControlSize"); //floating_control->adjustSize(); QWidget *iw = floating_control->internalWidget(); QSize iws = iw->size(); QMargins m = floating_control->contentsMargins(); int new_height = iws.height() + m.top() + m.bottom(); if (new_height < 32) new_height = 32; floating_control->resize(floating_control->width(), new_height); }
void AMP_TabDockWinProjView::TabRaiseChange(void) { QWidget *ww = centralWidget (); if(ww == NULL) return; QSize ss = ww->size(); setMinimumSize(ss); // to ensure scroll function appear w.r.t. child widget size }
void FloatingStatusBar::Reposition() { QWidget* p = parentWidget(); QSize s = p->size() - this->size(); #ifdef Q_WS_MAC this->move(p->geometry().topLeft() + QPoint(0, s.height()) + QPoint(1,-1)); #elif defined(Q_CYGWIN_WIN) this->move(p->geometry().topLeft() + QPoint(0, s.height()) + QPoint(0, -6)); #else this->move(p->geometry().topLeft() + QPoint(0, s.height())); #endif }
bool LfmDelegate::eventFilter( QObject* obj, QEvent* event ) { if( event->type() == QEvent::Resize ) { QWidget* view = qobject_cast< QWidget* >(obj ); if( !view ) return false; m_viewSize = view->size(); emit sizeHintChanged( QModelIndex() ); } return false; }
void TabBar::mouseMoveEvent(QMouseEvent *event) { if(!(event->buttons() & Qt::LeftButton) || !tabsClosable()) return PlusTabBar::mouseMoveEvent(event); if((event->pos() - m_startDragPos).manhattanLength() < QApplication::startDragDistance()) return PlusTabBar::mouseMoveEvent(event); int idx = tabAt(event->pos()); if(idx == -1) return PlusTabBar::mouseMoveEvent(event); event->accept(); QDrag *drag = new QDrag(this); tabView()->createSplitOverlay(m_id, drag); QStyleOptionTabV3 tab; initStyleOption(&tab, idx); QWidget *tabWidget = ((QTabWidget*)parent())->widget(idx); QPixmap wMap(tabWidget->size()); tabWidget->render(&wMap); if(wMap.width() > 400 || wMap.height() > 400) wMap = wMap.scaled(400, 400, Qt::KeepAspectRatio, sConfig.get(CFG_BOOL_SMOOTH_SCALING) ? Qt::SmoothTransformation : Qt::FastTransformation); QSize size = tabRect(idx).size(); size.rwidth() = std::max(wMap.width(), size.width()); size.rheight() += wMap.height(); QPixmap map(size); map.fill(Qt::transparent); QStylePainter p(&map, this); p.initFrom(this); p.drawItemPixmap(QRect(0, tab.rect.height()-5, wMap.width(), wMap.height()), 0, wMap); tab.rect.moveTopLeft(QPoint(0, 0)); p.drawControl(QStyle::CE_TabBarTab, tab); p.end(); QMimeData *mime = new QMimeData(); mime->setData("data/tabinfo", QString("%1 %2 %3").arg(m_id).arg(idx).arg(tabView()->getWindowId()).toLatin1()); drag->setPixmap(map); drag->setMimeData(mime); drag->exec(); delete drag; }
void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition) { #ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1 QWidget *pTopLevelWidget = window(); /* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized: */ if (pTopLevelWidget->isMaximized()) return; /* Calculate client window offsets: */ QRect frameGeo = pTopLevelWidget->frameGeometry(); QRect geo = pTopLevelWidget->geometry(); int dl = geo.left() - frameGeo.left(); int dt = geo.top() - frameGeo.top(); int dr = frameGeo.right() - geo.right(); int db = frameGeo.bottom() - geo.bottom(); /* Get the best size w/o scroll bars: */ QSize s = pTopLevelWidget->sizeHint(); /* Resize the frame to fit the contents: */ s -= pTopLevelWidget->size(); frameGeo.setRight(frameGeo.right() + s.width()); frameGeo.setBottom(frameGeo.bottom() + s.height()); if (bAdjustPosition) { QRegion availableGeo; QDesktopWidget *dwt = QApplication::desktop(); if (dwt->isVirtualDesktop()) /* Compose complex available region */ for (int i = 0; i < dwt->numScreens(); ++ i) availableGeo += dwt->availableGeometry(i); else /* Get just a simple available rectangle */ availableGeo = dwt->availableGeometry(pTopLevelWidget->pos()); frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo, vboxGlobal().vmRenderMode() != SDLMode /* can resize? */); } #if 0 /* Center the frame on the desktop: */ frameGeo.moveCenter(availableGeo.center()); #endif /* Finally, set the frame geometry */ pTopLevelWidget->setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, frameGeo.width() - dl - dr, frameGeo.height() - dt - db); #else /* !VBOX_GUI_WITH_CUSTOMIZATIONS1 */ Q_UNUSED(bAdjustPosition); #endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */ }
QImage dtkComposerNodeLeafView::screenshot(void) const { QWidget *widget = d->view->widget(); QPixmap pixmap(widget->size()); widget->render(&pixmap); if( pixmap.width() > 1920) { // limit width to FULL HD res. return pixmap.scaledToWidth(1920).toImage(); } return pixmap.toImage(); }
void QMxWindow::dragPointResize(int x, int y) { QPoint newPoint(x,y); if(resizeValid){ QWidget* window = scene()->views().first()->window(); QPoint delta = newPoint - lastResizePoint; window->resize(window->size() + QSize(delta.x(), delta.y())); newPoint -= delta;//Because it's anchored to the corner, it moves too! }else{ resizeValid = true; } lastResizePoint = newPoint; }
QSize ExpandingDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { QSize s = QItemDelegate::sizeHint(option, index); if (model()->isExpanded(index) && model()->expandingWidget(index)) { QWidget *widget = model()->expandingWidget(index); QSize widgetSize = widget->size(); s.setHeight(widgetSize.height() + s.height() + 10); //10 is the sum that must match exactly the offsets used in ExpandingWidgetModel::placeExpandingWidgets } else if (model()->isPartiallyExpanded(index)) { s.setHeight(s.height() + 30 + 10); } return s; }
void MyScrollArea::updateArea() { //! [1] QSize areaSize = viewport()->size(); QSize widgetSize = widget->size(); verticalScrollBar()->setPageStep(areaSize.height()); horizontalScrollBar()->setPageStep(areaSize.width()); verticalScrollBar()->setRange(0, widgetSize.height() - areaSize.height()); horizontalScrollBar()->setRange(0, widgetSize.width() - areaSize.width()); updateWidgetPosition(); //! [1] }
void ResizeFrame::mouseMoveEvent(QMouseEvent *event) { QPoint dpos = event->pos() - mousePos; QWidget* p = dynamic_cast<QWidget*>(QFrame::parent()->parent()); int w = p->size().width(); int h = p->size().height(); int minw; int minh; if (p->minimumSizeHint().isValid()) { minw = p->minimumSizeHint().width(); minh = p->minimumSizeHint().height(); } else { minw = p->minimumWidth() > 0 ? p->minimumWidth() : 24; minh = p->minimumHeight() > 0 ? p->minimumHeight() : 24; } // The minimum size will only be enforced if the widget is being // shrunk, and its size is larger than its minimum size. (If, for some // reason, the widget's size is already *smaller* than its minimum // size, and the user is actually trying to *shrink* it, then it would // be rather odd to *enlarge* the widget to its minimum size.) if (w + dpos.x() >= minw) w += dpos.x(); else if (w > minw && dpos.x() < 0) w = minw; if (h + dpos.y() >= minh) h += dpos.y(); else if (h > minh && dpos.y() < 0) h = minh; p->setUpdatesEnabled(false); p->resize(w, h); p->setUpdatesEnabled(true); }