本文整理汇总了C++中ToolBar::setGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ ToolBar::setGeometry方法的具体用法?C++ ToolBar::setGeometry怎么用?C++ ToolBar::setGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToolBar
的用法示例。
在下文中一共展示了ToolBar::setGeometry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: layoutToolBarRow
void ToolBarAreaImpl::layoutToolBarRow(ToolBarRowPtr toolBarRow, int& io_rowTop, bool isNewBottomRow)
{
int rowHeight = 0;
bool draggedToolBarExists = false;
ToolBarList& toolBars = toolBarRow->toolBars;
// calculate the row height and remove the dragged tool bar if it is originally in this row
ToolBarList::iterator p = toolBars.begin();
while(p != toolBars.end()){
ToolBar* toolBar = *p;
if(toolBar == draggedToolBar){
draggedToolBarExists = true;
p = toolBars.erase(p);
} else {
rowHeight = std::max(rowHeight, toolBar->sizeHint().height());
++p;
}
}
// Is the dragged tool bar moving to this row ?
bool isDraggedToolBarMovingToThisRow = false;
if(draggedToolBarHasNotBeenInserted){
int bottomBorder = 0;
if(rowHeight == 0 && draggedToolBarExists){
int h = draggedToolBar->sizeHint().height();
bottomBorder = io_rowTop + h * 4 / 5;
} else {
bottomBorder = io_rowTop + rowHeight;
}
if(dragY < bottomBorder || isNewBottomRow){
isDraggedToolBarMovingToThisRow = true;
rowHeight = std::max(rowHeight, draggedToolBar->sizeHint().height());
layoutToolBarRowWithDraggedToolBar(toolBars, io_rowTop, rowHeight);
}
}
if(toolBars.empty()){
toolBarRow->separator.hide();
} else {
if(!isDraggedToolBarMovingToThisRow){
layoutToolBarRowPart(toolBars, io_rowTop, rowHeight, 0, self->width());
}
for(ToolBarList::iterator p = toolBars.begin(); p != toolBars.end(); ++p){
ToolBar* toolBar = *p;
if(toolBar->height() != rowHeight){
toolBar->setGeometry(toolBar->x(), io_rowTop, toolBar->width(), rowHeight);
}
}
io_rowTop += rowHeight;
HSeparator& sep = toolBarRow->separator;
int h = sep.sizeHint().height();
sep.setGeometry(0, io_rowTop, self->width(), h);
sep.show();
io_rowTop += sep.sizeHint().height();
}
}