本文整理汇总了C++中ToolBar::isStretchable方法的典型用法代码示例。如果您正苦于以下问题:C++ ToolBar::isStretchable方法的具体用法?C++ ToolBar::isStretchable怎么用?C++ ToolBar::isStretchable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToolBar
的用法示例。
在下文中一共展示了ToolBar::isStretchable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expandStrechableBars
void ToolBarAreaImpl::expandStrechableBars
(ToolBarRowPtr& row, int portion, int shift, int barIndex, int numStrechables, int lastSpace)
{
ToolBar* bar = row->toolBars[barIndex];
bar->desiredX += shift;
if(bar->isStretchable()){
int addition = (numStrechables > 1) ? portion : lastSpace;
shift += addition;
lastSpace -= addition;
--numStrechables;
}
++barIndex;
if(barIndex < (int)row->toolBars.size()){
expandStrechableBars(row, portion, shift, barIndex, numStrechables, lastSpace);
}
}
示例2: layoutToolBarRowPart
void ToolBarAreaImpl::layoutToolBarRowPart
(ToolBarList& toolBars, int rowTop, int rowHeight, int partLeft, int partRight)
{
// find the index of the tool bar with the maximum priority
int pivotIndex = 0;
int maxPriority = -1;
for(size_t i=0; i < toolBars.size(); ++i){
if(toolBars[i]->layoutPriority > maxPriority){
maxPriority = toolBars[i]->layoutPriority;
pivotIndex = i;
}
}
ToolBarList leftPartToolBars;
int pivotAreaLeft = partLeft;
for(int i=0; i < pivotIndex; ++i){
leftPartToolBars.push_back(toolBars[i]);
pivotAreaLeft += toolBars[i]->minimumSizeHint().width();
}
ToolBarList rightPartToolBars;
int pivotAreaRight = partRight;
for(size_t i = pivotIndex + 1; i < toolBars.size(); ++i){
rightPartToolBars.push_back(toolBars[i]);
pivotAreaRight -= toolBars[i]->minimumSizeHint().width();
}
ToolBar* pivotToolBar = toolBars[pivotIndex];
int x = pivotToolBar->desiredX;
const QSize size = pivotToolBar->minimumSizeHint();
int width = size.width();
if(width < 0){
width = 0;
}
if(x + width > pivotAreaRight){
x = pivotAreaRight - width;
}
if(x < pivotAreaLeft){
x = pivotAreaLeft;
}
if(!leftPartToolBars.empty()){
layoutToolBarRowPart(leftPartToolBars, rowTop, rowHeight, partLeft, x);
QRect r = leftPartToolBars.back()->geometry();
int leftPartRight = r.x() + r.width();
if(x <= leftPartRight){
x = leftPartRight + 1;
}
}
int rightPartLeft = partRight;
if(!rightPartToolBars.empty()){
layoutToolBarRowPart(rightPartToolBars, rowTop, rowHeight, x + width, partRight);
rightPartLeft = rightPartToolBars.front()->geometry().x();
}
if(pivotToolBar->isStretchable()){
width = pivotToolBar->maximumWidth();
int possibleWidth = rightPartLeft - x;
if(width > possibleWidth){
width = possibleWidth;
}
}
int height = (size.height() >= 0) ? size.height() : rowHeight;
int y = rowTop + (rowHeight - height) / 2;
pivotToolBar->setGeometry(x, y, width, height);
pivotToolBar->show();
}