本文整理汇总了C++中QSplitter::sizes方法的典型用法代码示例。如果您正苦于以下问题:C++ QSplitter::sizes方法的具体用法?C++ QSplitter::sizes怎么用?C++ QSplitter::sizes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSplitter
的用法示例。
在下文中一共展示了QSplitter::sizes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 ();
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: 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;
}
示例5: 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);
}
}
}
}
示例6: 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();
}
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: saveSettings
void PropertiesWidget::saveSettings() {
QIniSettings settings;
settings.setValue("TorrentProperties/Visible", state==VISIBLE);
// Splitter sizes
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
QList<int> sizes;
if (state == VISIBLE)
sizes = hSplitter->sizes();
else
sizes = slideSizes;
qDebug("Sizes: %d", sizes.size());
if (sizes.size() == 2) {
settings.setValue(QString::fromUtf8("TorrentProperties/SplitterSizes"), QVariant(QString::number(sizes.first())+','+QString::number(sizes.last())));
}
settings.setValue("TorrentProperties/FilesListState", filesList->header()->saveState());
// Remember current tab
settings.setValue("TorrentProperties/CurrentTab", m_tabBar->currentIndex());
}
示例11: expandTabs
void GTUtilsWorkflowDesigner::expandTabs(HI::GUITestOpStatus &os){
QSplitter* splitter = qobject_cast<QSplitter*>(GTWidget::findWidget(os,"splitter"));
GT_CHECK(splitter, "splitter not found");
QList<int> s;
s = splitter->sizes();
if(s.first()==0){//expands tabs if collapsed
QPoint p;
p.setX(splitter->geometry().left()+2);
p.setY(splitter->geometry().center().y());
GTMouseDriver::moveTo(os, p);
GTGlobals::sleep(300);
GTMouseDriver::press(os);
p.setX(p.x()+200);
GTMouseDriver::moveTo(os,p);
GTMouseDriver::release(os);
}
}
示例12: saveSettings
void PropertiesWidget::saveSettings() {
Preferences* const pref = Preferences::instance();
pref->setPropVisible(state==VISIBLE);
// Splitter sizes
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
QList<int> sizes;
if (state == VISIBLE)
sizes = hSplitter->sizes();
else
sizes = slideSizes;
qDebug("Sizes: %d", sizes.size());
if (sizes.size() == 2) {
pref->setPropSplitterSizes(QString::number(sizes.first()) + ',' + QString::number(sizes.last()));
}
pref->setPropFileListState(filesList->header()->saveState());
// Remember current tab
pref->setPropCurTab(m_tabBar->currentIndex());
}
示例13: set_widget_height
static void set_widget_height(int height){
return;
#if 0
QWidget *main_window = static_cast<QWidget*>(root->song->tracker_windows->os_visual.main_window);
EditorWidget *editor = static_cast<EditorWidget*>(root->song->tracker_windows->os_visual.widget);
QSplitter *splitter = editor->ysplitter;
#if USE_QT4
# define QValueList QList
#endif
//printf("set_widghet_height. main_window->height(): %d, splitter: %p\n",main_window->height(),splitter);
QValueList<int> currentSizes = splitter->sizes();
currentSizes[0] = main_window->height() - height;
currentSizes[1] = height;
splitter->setSizes(currentSizes);
#if USE_QT4
# undef QValueList
#endif
#endif // 0
}
示例14: main
int main()
{
QWidget *parent = 0;
//! [0]
QSplitter *splitter = new QSplitter(parent);
QListView *listview = new QListView;
QTreeView *treeview = new QTreeView;
QTextEdit *textedit = new QTextEdit;
splitter->addWidget(listview);
splitter->addWidget(treeview);
splitter->addWidget(textedit);
//! [0]
{
// SAVE STATE
//! [1]
QSettings settings;
settings.setValue("splitterSizes", splitter->saveState());
//! [1]
}
{
// RESTORE STATE
//! [2]
QSettings settings;
splitter->restoreState(settings.value("splitterSizes").toByteArray());
//! [2]
}
//! [3]
QListIterator<int> it(splitter->sizes());
while (it.hasNext())
processSize(it.next());
//! [3]
return 0;
}
示例15: applyStoredSize
void RightPanePlaceHolder::applyStoredSize(int width)
{
if (width) {
QSplitter *splitter = qobject_cast<QSplitter *>(parentWidget());
if (splitter) {
// A splitter we need to resize the splitter sizes
QList<int> sizes = splitter->sizes();
int index = splitter->indexOf(this);
int diff = width - sizes.at(index);
int adjust = sizes.count() > 1 ? (diff / (sizes.count() - 1)) : 0;
for (int i = 0; i < sizes.count(); ++i) {
if (i != index)
sizes[i] -= adjust;
}
sizes[index]= width;
splitter->setSizes(sizes);
} else {
QSize s = size();
s.setWidth(width);
resize(s);
}
}
}