本文整理汇总了C++中QSplitter::setSizes方法的典型用法代码示例。如果您正苦于以下问题:C++ QSplitter::setSizes方法的具体用法?C++ QSplitter::setSizes怎么用?C++ QSplitter::setSizes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSplitter
的用法示例。
在下文中一共展示了QSplitter::setSizes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update_sizes
void MVOverviewWidgetPrivate::update_sizes()
{
float W0=q->width();
float H0=q->height();
int W1=W0/3; if (W1<300) W1=300; if (W1>500) W1=500;
int W2=W0-W1;
if (W2<500) {W2=500; W1=W0-W2;}
int H1=H0/3;
int H2=H0/3;
int H3=H0-H1-H2;
{
QList<int> sizes; sizes << W1 << W2;
m_hsplitter->setSizes(sizes);
}
{
QList<int> sizes; sizes << H1 << H2 << H3;
m_vsplitter->setSizes(sizes);
}
int H1_left=H0/3;
int H2_left=H0/3;
int H3_left=H0-H1_left-H2_left;
{
QList<int> sizes; sizes << H1_left << H2_left << H3_left;
m_left_vsplitter->setSizes(sizes);
}
}
示例2: split
void SplitView::split(BufferView* view, Qt::Orientation orientation)
{
if (view) {
QSplitter* container = qobject_cast<QSplitter*>(view->parentWidget());
if (container) {
int index = container->indexOf(view);
BufferView* bv = 0;
const int size = (orientation == Qt::Horizontal ? container->width() : container->height()) - container->handleWidth();
if (container->count() == 1 || container->orientation() == orientation) {
container->setOrientation(orientation);
bv = createBufferView(container, index + 1);
QList<int> sizes;
for (int i = 0; i < container->count(); ++i)
sizes += size / container->count();
container->setSizes(sizes);
} else if (index != -1) {
QList<int> sizes = container->sizes();
QSplitter* splitter = wrap(view, orientation);
if (splitter) {
container->setSizes(sizes);
bv = createBufferView(splitter);
splitter->setSizes(QList<int>() << size/2 << size/2);
}
}
if (bv) {
bv->setBuffer(view->buffer());
emit viewAdded(bv);
}
}
}
}
示例3: splitView
void MultiViewWidget::splitView(Qt::Orientation orient,
ContainerWidget *container)
{
QVBoxLayout *widgetLayout = qobject_cast<QVBoxLayout *>(container->parent());
QSplitter *split = qobject_cast<QSplitter *>(container->parent());
if (!widgetLayout)
if (container->parent() == this)
widgetLayout = qobject_cast<QVBoxLayout *>(layout());
if (widgetLayout) {
QSplitter *splitter = new QSplitter(orient, this);
widgetLayout->removeWidget(container);
widgetLayout->addWidget(splitter);
splitter->addWidget(container);
container = createContainer();
splitter->addWidget(container);
QList<int> sizes;
int s = Qt::Horizontal ? splitter->size().width() / 2
: splitter->size().height() / 2;
sizes << s << s;
splitter->setSizes(sizes);
}
else if (split) {
QSplitter *splitter = new QSplitter(orient, this);
int idx = split->indexOf(container);
splitter->addWidget(container);
container = createContainer();
splitter->addWidget(container);
split->insertWidget(idx, splitter);
QList<int> sizes;
int s = Qt::Horizontal ? splitter->size().width() / 2
: splitter->size().height() / 2;
sizes << s << s;
splitter->setSizes(sizes);
}
}
示例4: setVisibility
void PropertiesWidget::setVisibility(bool visible)
{
if (!visible && (state == VISIBLE)) {
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
m_ui->stackedProperties->setVisible(false);
slideSizes = hSplitter->sizes();
hSplitter->handle(1)->setVisible(false);
hSplitter->handle(1)->setDisabled(true);
QList<int> sizes = QList<int>() << hSplitter->geometry().height() - 30 << 30;
hSplitter->setSizes(sizes);
state = REDUCED;
return;
}
if (visible && (state == REDUCED)) {
m_ui->stackedProperties->setVisible(true);
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
hSplitter->handle(1)->setDisabled(false);
hSplitter->handle(1)->setVisible(true);
hSplitter->setSizes(slideSizes);
state = VISIBLE;
// Force refresh
loadDynamicData();
}
}
示例5: splitViewSpace
void KateViewManager::splitViewSpace( KateViewSpace* vs, // = 0
Qt::Orientation o )// = Qt::Horizontal
{
// emergency: fallback to activeViewSpace, and if still invalid, abort
if (!vs) vs = activeViewSpace();
if (!vs) return;
// get current splitter, and abort if null
QSplitter *currentSplitter = qobject_cast<QSplitter*>(vs->parentWidget());
if (!currentSplitter) return;
// index where to insert new splitter/viewspace
const int index = currentSplitter->indexOf( vs );
// create new viewspace
KateViewSpace* vsNew = new KateViewSpace( this );
// only 1 children -> we are the root container. So simply set the orientation
// and add the new view space, then correct the sizes to 50%:50%
if (currentSplitter->count() == 1)
{
if( currentSplitter->orientation() != o )
currentSplitter->setOrientation( o );
QList<int> sizes = currentSplitter->sizes();
sizes << (sizes.first() - currentSplitter->handleWidth() ) / 2;
sizes[0] = sizes[1];
currentSplitter->insertWidget( index, vsNew );
currentSplitter->setSizes( sizes );
}
else
{
// create a new QSplitter and replace vs with the splitter. vs and newVS are
// the new children of the new QSplitter
QSplitter* newContainer = new QSplitter( o );
newContainer->setOpaqueResize( KGlobalSettings::opaqueResize() );
QList<int> currentSizes = currentSplitter->sizes();
newContainer->addWidget( vs );
newContainer->addWidget( vsNew );
currentSplitter->insertWidget( index, newContainer );
newContainer->show();
// fix sizes of children of old and new splitter
currentSplitter->setSizes( currentSizes );
QList<int> newSizes = newContainer->sizes();
newSizes[0] = (newSizes[0] + newSizes[1] - newContainer->handleWidth()) / 2;
newSizes[1] = newSizes[0];
newContainer->setSizes( newSizes );
}
m_viewSpaceList.append( vsNew );
activeViewSpace()->setActive( false );
vsNew->setActive( true, true );
vsNew->show();
createView ((KTextEditor::Document*)activeView()->document());
updateViewSpaceActions ();
}
示例6: split
//!
//! Splits the panel frame according to the given orientation.
//!
//! \param orientation The orientation in which to split the panel frame.
//!
void PanelFrame::split ( Qt::Orientation orientation )
{
QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
QSplitter *parentSplitter = qobject_cast<QSplitter *>(parentWidget());
parentSplitter->setHandleWidth(1);
if (!parentSplitter && !mainWindow) {
QMessageBox::information(this, "Split Panel", "Splitting this panel is not possible.");
return;
}
// flip the orientation
if (orientation == Qt::Horizontal)
orientation = Qt::Vertical;
else
orientation = Qt::Horizontal;
// save the size of this panel
QSize panelSize = size();
int widthHeight = orientation == Qt::Horizontal ? panelSize.width() : panelSize.height();
// clone this panel frame
PanelFrame *clonedPanelFrame = new PanelFrame(m_panelType, parentWidget(), windowFlags());
QList<int> sizes;
int panelIndex;
if (parentSplitter) {
// save the parent splitter's sizes
sizes = parentSplitter->sizes();
// obtain the index of this panel in its parent splitter
panelIndex = parentSplitter->indexOf(this);
}
// create new splitter for this panel and its clone
QSplitter *newSplitter = new QSplitter(orientation);
newSplitter->setHandleWidth(1);
newSplitter->addWidget(this);
newSplitter->addWidget(clonedPanelFrame);
// give both panels in the new splitter the same space
QList<int> newSizes;
newSizes << widthHeight / 2 << widthHeight / 2;
newSplitter->setSizes(newSizes);
if (parentSplitter) {
// insert the new splitter into the panel's former parent splitter
parentSplitter->insertWidget(panelIndex, newSplitter);
// restore the parent splitter's sizes
parentSplitter->setSizes(sizes);
} else {
mainWindow->setCentralWidget(newSplitter);
}
}
示例7: createDockWindows
void FenPrincipale::createDockWindows()
{
QDockWidget *dockDonnee = new QDockWidget(tr("Données"), this);
dockDonnee->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::RightDockWidgetArea, dockDonnee);
QSplitter *splitter = new QSplitter(dockDonnee);
QSize size(800,800);
splitter->setMinimumSize(size);
splitter->addWidget(tablemesures);
splitter->addWidget(tabless);
splitter->setOrientation(Qt::Vertical);
QList<int> list = QList<int>() << 800 << 800;
splitter->setSizes(list);
viewMenu->addAction(dockDonnee->toggleViewAction());
QDockWidget *dockCalcul = new QDockWidget(tr("Calculs"), this);
addDockWidget(Qt::RightDockWidgetArea, dockCalcul);
viewMenu->addAction(dockCalcul->toggleViewAction());
// QSplitter *splitter = new QSplitter(dockDonnee);
// splitter->addWidget(tabless);
// splitter->addWidget(tablemesures);
// QList<int> list = QList<int>() << 150 << 150;
// splitter->setSizes(list);
}
示例8: onCommentsButtonClicked
void TitleBar::onCommentsButtonClicked()
{
#ifdef USEWEBENGINE
QWebEngineView* comments = noteView()->commentView();
#else
QWebView* comments = noteView()->commentView();
#endif
if (comments->isVisible()) {
comments->hide();
return;
}
if (isNetworkAccessible()) {
if (!m_commentsUrl.isEmpty()) {
comments->load(m_commentsUrl);
QSplitter* splitter = qobject_cast<QSplitter*>(comments->parentWidget());
Q_ASSERT(splitter);
QList<int> li = splitter->sizes();
Q_ASSERT(li.size() == 2);
QList<int> lin;
lin.push_back(li.value(0) - COMMENT_FRAME_WIDTH);
lin.push_back(li.value(1) + COMMENT_FRAME_WIDTH);
splitter->setSizes(lin);
comments->show();
} else {
loadErrorPage();
comments->show();
}
} else {
m_commentsBtn->setEnabled(false);
}
}
示例9: setupLayout
void DlgCustomizeSpaceball::setupLayout()
{
QLabel *buttonLabel = new QLabel(tr("Buttons"), this);
clearButton = new QPushButton(tr("Clear"), this);
QVBoxLayout *buttonGroup = new QVBoxLayout();
buttonGroup->addWidget(buttonLabel);
buttonGroup->addWidget(buttonView);
QHBoxLayout *clearLayout = new QHBoxLayout();
clearLayout->addWidget(clearButton);
clearLayout->addStretch();
buttonGroup->addLayout(clearLayout);
QSplitter *splitter = new QSplitter(this);
QWidget *leftPane = new QWidget(this);
leftPane->setLayout(buttonGroup);
splitter->addWidget(leftPane);
splitter->addWidget(commandView);
printReference = new QPushButton(tr("Print Reference"), this);
QHBoxLayout *printLayout = new QHBoxLayout();
printLayout->addStretch();
printLayout->addWidget(printReference);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(splitter);
layout->addLayout(printLayout);
this->setLayout(layout);
QList<int> sizes;
sizes << this->size().width()*0.40;
sizes << this->size().width()-sizes.at(0);
splitter->setSizes(sizes);
}
示例10: eventFilter
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;
}
示例11: QSplitter
AnnoqtConfEditor::AnnoqtConfEditor() : m_colorNames2EntityTypes(), m_entityTypes2ColorNames(), m_currentColor(QColor(Qt::black)), m_currentAnnotationConfigurationFile(),m_currentDirectory(),
m_currentItem(0)
{
QFont font = QApplication::font();
font.setPointSize(12);
QApplication::setFont(font);
QSplitter *splitter = new QSplitter( this );
setCentralWidget( splitter );
m_listWidget = new QListWidget();
splitter->addWidget( m_listWidget );
m_colorPicker = new KColorDialog(this);
m_colorPicker->setColor( Qt::white );
splitter->addWidget( m_colorPicker );
QList<int> l;
l.push_back( 100 );
l.push_back( 600 );
splitter->setSizes( l );
createActions();
createMenus();
createToolBars();
createStatusBar();
readSettings();
connect( m_listWidget, SIGNAL( itemClicked ( QListWidgetItem* ) ),
this, SLOT( slotTypesListItemclicked( QListWidgetItem* ) ) );
connect( m_colorPicker, SIGNAL(colorSelected( const QColor & )), this, SLOT(slotColorSelected( const QColor& )) );
}
示例12: QGLViewer
MainWindow::MainWindow(QWidget *parent):QMainWindow(parent)
{
setMinimumSize(20, 20);
resize(1500, 900);
glViewer = new QGLViewer(this);
m_parameter_control = new ParameterControl(glViewer, this);
createActions();
createMenus();
createToolBars();
QList <int> sizes;
sizes<<1200<<300;
QSplitter* mainSplitter = new QSplitter(Qt::Horizontal);
mainSplitter->addWidget(glViewer);
mainSplitter->addWidget(m_parameter_control);
mainSplitter->setSizes(sizes);
mainSplitter->setStretchFactor(0, 1);
setCentralWidget(mainSplitter);
setWindowTitle("Parameter");
}
示例13: maximizeWidget
//!
//! Maximizes the given widget inside its parent widget.
//!
//! The widget can be a panel frame or a splitter widget.
//!
//! \param widget The widget to maximize.
//!
void PanelFrame::maximizeWidget ( QWidget *widget )
{
QWidget *parentWidget = widget->parentWidget();
QSplitter *parentSplitter = qobject_cast<QSplitter *>(parentWidget);
parentSplitter->setHandleWidth(1);
if (!parentSplitter) {
QMessageBox::information(this, "Maximize Panel", "The panel is already maximized.");
return;
}
int index = parentSplitter->indexOf(widget);
QList<int> sizes = parentSplitter->sizes();
// count number of visible panel frames
int visiblePanelFrames = 0;
for (int i = 0; i < sizes.size(); ++i)
if (sizes[i] > 0)
++visiblePanelFrames;
if (visiblePanelFrames == 1)
maximizeWidget(parentSplitter);
else {
// hide all other panels in the same splitter
for (int i = 0; i < sizes.size(); ++i)
if (i != index)
sizes[i] = 0;
parentSplitter->setSizes(sizes);
}
}
示例14: minimizeWidget
//!
//! Minimizes the given widget inside its parent widget.
//!
//! The widget can be a panel frame or a splitter widget.
//!
//! \param widget The widget to minimize.
//!
void PanelFrame::minimizeWidget ( QWidget *widget )
{
QWidget *parentWidget = widget->parentWidget();
QSplitter *parentSplitter = qobject_cast<QSplitter *>(parentWidget);
parentSplitter->setHandleWidth(1);
if (!parentSplitter) {
QMessageBox::information(this, "Minimize Panel", "The last visible panel cannot be minimized.");
return;
}
int index = parentSplitter->indexOf(widget);
QList<int> sizes = parentSplitter->sizes();
// count number of visible panel frames
int visiblePanelFrames = 0;
for (int i = 0; i < sizes.size(); ++i)
if (sizes[i] > 0)
++visiblePanelFrames;
if (visiblePanelFrames == 1)
minimizeWidget(parentSplitter);
else {
sizes[index] = 0;
parentSplitter->setSizes(sizes);
}
}
示例15: dropViewInsidePane
void ViewAreaImpl::dropViewInsidePane(ViewPane* pane, View* view, int dropEdge)
{
if(dropEdge == OVER){
addView(pane, view, true);
} else {
QSize destSize = pane->size();
QSplitter* parentSplitter = static_cast<QSplitter*>(pane->parentWidget());
if(parentSplitter->count() >= 2){
QList<int> sizes = parentSplitter->sizes();
QSplitter* newSplitter = new QSplitter(parentSplitter);
parentSplitter->insertWidget(parentSplitter->indexOf(pane), newSplitter);
newSplitter->addWidget(pane);
parentSplitter->setSizes(sizes);
parentSplitter = newSplitter;
}
ViewPane* newViewPane = new ViewPane(this, parentSplitter);
if(dropEdge == LEFT){
parentSplitter->setOrientation(Qt::Horizontal);
parentSplitter->insertWidget(0, newViewPane);
} else if(dropEdge == RIGHT){
parentSplitter->setOrientation(Qt::Horizontal);
parentSplitter->insertWidget(1, newViewPane);
} else if(dropEdge == TOP){
parentSplitter->setOrientation(Qt::Vertical);
parentSplitter->insertWidget(0, newViewPane);
} else {
parentSplitter->setOrientation(Qt::Vertical);
parentSplitter->insertWidget(1, newViewPane);
}
addView(newViewPane, view, true);
int half;
if(parentSplitter->orientation() == Qt::Horizontal){
half = destSize.height() / 2;
} else {
half = destSize.width() / 2;
}
QList<int> sizes;
sizes << half << half;
parentSplitter->setSizes(sizes);
}
}