当前位置: 首页>>代码示例>>C++>>正文


C++ QScrollBar::setMinimum方法代码示例

本文整理汇总了C++中QScrollBar::setMinimum方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollBar::setMinimum方法的具体用法?C++ QScrollBar::setMinimum怎么用?C++ QScrollBar::setMinimum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QScrollBar的用法示例。


在下文中一共展示了QScrollBar::setMinimum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: paintEvent

///Generates renderObjectCollections when required, i.e.
///when re-sized, molecule altered; adjusts the vertical scrollbar,
///and paints all visible renderOjbectCollections
void RenderArea::paintEvent(QPaintEvent *)
{
  //First, let's see how big the window is and how many bases we can spanIdRole
    QFont font("Courier", 14, QFont::Normal);						//need fixed width font
    QPainter painter(viewport());
    painter.setFont(font);
    QFontMetrics fm(font);
    int charWidth   = fm.width("cagtnrlpyt") / 10;	//width of each cha
    int lineHeight  = charWidth*3;            //fm.height("cagtnrlpyt");
    int numberWidth = round(log10(pMol->sequence.length())) * charWidth + charWidth ;
    int basePerLine = (width()-numberWidth-32)/charWidth;

    int currentBase = 0;
    QString number = QString();
    QScrollBar* scrollbar = verticalScrollBar();

    //we go here and re-virtual-render everything if the window has been re-sized 
    //as well as adjusting the vertical scroll bar
    if (reSized)
    {
       float r = ((float) scrollbar->sliderPosition())/((float) totalHeight);           //get relative position of where we are
       while (!renderObjects.isEmpty()) delete renderObjects.takeFirst();		//clean up previous render Elements

       totalHeight = 0;									//clear cumulative height
       do {
         qDebug() << "---------Line----------" << currentBase;
         RenderObjectContainer* container = pMol->renderSequenceDump(NULL, currentBase,currentBase+basePerLine, charWidth);
         renderObjects.append(container);
         currentBase += basePerLine;
         totalHeight+=container->rect.height();						//measure total height of render
       } while ((currentBase + basePerLine)<(pMol->sequence.length()));

       scrollbar->setMinimum(1);							//re-set the scrollbar
       scrollbar->setMaximum(totalHeight-height()+100);					//leave a bit of room at the bottom	
       scrollbar->setPageStep(height());						//adjust the page step to the view port's size
       scrollbar->setSliderPosition(round(r*totalHeight));				//set the slider position correctly from the relative value we had stored
       scrollbar->setSingleStep(charWidth);

       reSized = false;								//label as reSized!
    } 

    //This bit paints only the renderObjectContainers above that are visible on this viewport

    int y = 1; //renderObjects.at(1)->rect.height();
    int virtualy = scrollbar->sliderPosition();

    for (int i = 0; i < renderObjects.size(); ++i)					//ok let's paint what is visible in the view-port
    {
      y+= renderObjects.at(i)->rect.height();
      if (y>=virtualy) renderObjects.at(i)->Render(&painter, numberWidth, y-virtualy); //only if visible
      if (y>(virtualy + height())) break;						//if over the edge of the view port, stop looping
    }
}
开发者ID:mxpule,项目名称:pMol0174,代码行数:56,代码来源:renderarea.cpp

示例2: updateScrollBar

void QConsolePrivate::updateScrollBar (void)
{
  m_scrollBar->setMinimum (0);
  if (m_bufferSize.height () > m_consoleRect.height ())
    m_scrollBar->setMaximum (m_bufferSize.height () - m_consoleRect.height ());
  else
    m_scrollBar->setMaximum (0);
  m_scrollBar->setSingleStep (1);
  m_scrollBar->setPageStep (m_consoleRect.height ());
  m_scrollBar->setValue (m_consoleRect.top ());

  log ("Scrollbar parameters updated: %d/%d/%d/%d\n",
       m_scrollBar->minimum (), m_scrollBar->maximum (),
       m_scrollBar->singleStep (), m_scrollBar->pageStep ());
}
开发者ID:RTOSkit,项目名称:Octave-UPM-TE,代码行数:15,代码来源:QWinTerminalImpl.cpp

示例3: RebuildEditView


//.........这里部分代码省略.........
        QLabel* label = new QLabel(QString::fromStdString(texname), mat_panel);
        label->resize(200,20);
        label->move(0, y*itemheight);
        label->show();
    }

    // Attachments
    ClearPanel(attachment_panel);
    const AvatarAttachmentVector& attachments = appearance->GetAttachments();
    attachment_panel->resize(width, itemheight * (attachments.size() + 1));

    for (uint y = 0; y < attachments.size(); ++y)
    {
        QPushButton* button = new QPushButton("Remove", attachment_panel);
        button->setObjectName(QString::fromStdString(ToString<int>(y))); // Attachment index
        button->resize(50, 20);
        button->move(width - 50, y*itemheight);
        button->show();

        QObject::connect(button, SIGNAL(clicked()), this, SLOT(RemoveAttachment()));

        std::string attachment_name = attachments[y].name_;
        // Strip away .xml from the attachment name for slightly nicer display
        std::size_t pos = attachment_name.find(".xml");
        if (pos != std::string::npos)
            attachment_name = attachment_name.substr(0, pos);

        QLabel* label = new QLabel(QString::fromStdString(attachment_name), attachment_panel);
        label->resize(200,20);
        label->move(0, y*itemheight);
        label->show();
    }

    // Modifiers
    QTabWidget* tabs = avatar_widget_->findChild<QTabWidget *>("tab_appearance");
    if (!tabs)
        return;
    for (;;)
    {
        QWidget* tab = tabs->widget(0);
        if (!tab)
            break;
        tabs->removeTab(0);
        delete tab;
    }

    const MasterModifierVector& master_modifiers = appearance->GetMasterModifiers();
    // If no master modifiers, show the individual morph/bone controls
    if (!master_modifiers.size())
    {
        QWidget* morph_panel = GetOrCreateTabScrollArea(tabs, "Morphs");
        QWidget* bone_panel = GetOrCreateTabScrollArea(tabs, "Bones");
        if (!morph_panel || !bone_panel)
            return;

        const BoneModifierSetVector& bone_modifiers = appearance->GetBoneModifiers();
        const MorphModifierVector& morph_modifiers = appearance->GetMorphModifiers();
        morph_panel->resize(tab_width, itemheight * (morph_modifiers.size() + 1));
        bone_panel->resize(tab_width, itemheight * (bone_modifiers.size() + 1));

        for (uint i = 0; i < bone_modifiers.size(); ++i)
        {
            QScrollBar* slider = new QScrollBar(Qt::Horizontal, bone_panel);
            slider->setObjectName(QString::fromStdString(bone_modifiers[i].name_));
            slider->setMinimum(0);
            slider->setMaximum(100);
            slider->setPageStep(10);
            slider->setValue(bone_modifiers[i].value_ * 100.0f);
            slider->resize(150, 20);
            slider->move(tab_width - 150, i * itemheight);
            slider->show();

            QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(BoneModifierValueChanged(int)));

            QLabel* label = new QLabel(QString::fromStdString(bone_modifiers[i].name_), bone_panel);
            label->resize(100,20);
            label->move(0, i * itemheight);
            label->show();
        }

        for (uint i = 0; i < morph_modifiers.size(); ++i)
        {
            QScrollBar* slider = new QScrollBar(Qt::Horizontal, morph_panel);
            slider->setObjectName(QString::fromStdString(morph_modifiers[i].name_));
            slider->setMinimum(0);
            slider->setMaximum(100);
            slider->setPageStep(10);
            slider->setValue(morph_modifiers[i].value_ * 100.0f);
            slider->resize(150, 20);
            slider->move(tab_width - 150, i * itemheight);
            slider->show();

            QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(MorphModifierValueChanged(int)));

            QLabel* label = new QLabel(QString::fromStdString(morph_modifiers[i].name_), morph_panel);
            label->resize(100,20);
            label->move(0, i * itemheight);
            label->show();
        }
    }
开发者ID:enne,项目名称:naali,代码行数:101,代码来源:AvatarEditor.cpp

示例4: paintEvent

void CtrlRegisterList::paintEvent(QPaintEvent *)
{

	int numRowsTotal = cpu->GetNumRegsInCategory(category);
	int maxRowsDisplay =rect().bottom()/rowHeight - 1;

	selection = std::min(std::max(selection,0),numRowsTotal);
	curVertOffset = std::max(std::min(curVertOffset,numRowsTotal - maxRowsDisplay),0);

	QScrollBar *bar = findChild<QScrollBar*>("RegListScroll");
	if(bar)
	{
		bar->setMinimum(0);
		bar->setMaximum(numRowsTotal - maxRowsDisplay);
		bar->setPageStep(1);
		bar->setValue(curVertOffset);
	}


	QPainter painter(this);
	painter.setBrush(Qt::white);
	painter.setPen(Qt::white);
	painter.drawRect(rect());

	if (!cpu)
		return;

	QFont normalFont = QFont("Arial", 10);
	painter.setFont(normalFont);

	int width = rect().width();

	QColor bgColor(0xffffff);
	QPen nullPen(bgColor);
	QPen currentPen(QColor(0xFF000000));
	QPen selPen(0x808080);
	QPen textPen;

	QBrush lbr;
	lbr.setColor(bgColor);
	QBrush nullBrush(bgColor);
	QBrush currentBrush(0xFFEfE8);
	QBrush pcBrush(0x70FF70);

	int nc = cpu->GetNumCategories();
	for (int i=0; i<nc; i++)
	{
		painter.setPen(i==category?currentPen:nullPen);
		painter.setBrush(i==category?pcBrush:nullBrush);
		painter.drawRect(width*i/nc,0,width*(i+1)/nc - width*i/nc -1,rowHeight-1);
		QString name = cpu->GetCategoryName(i);
		painter.setPen(currentPen);
		painter.drawText(width*i/nc+1,-3+rowHeight,name);
	}

	int numRows=rect().bottom()/rowHeight;

	for (int i=curVertOffset; i<curVertOffset+numRows; i++)
	{
		int rowY1 = rowHeight*(i-curVertOffset+1);
		int rowY2 = rowHeight*(i-curVertOffset+2)-1;

		lbr.setColor(i==selection?0xffeee0:0xffffff);

		painter.setBrush(currentBrush);
		painter.setPen(nullPen);
		painter.drawRect(0,rowY1,16-1,rowY2-rowY1);

		if (selecting && i == selection)
			painter.setPen(selPen);
		else
			painter.setPen(nullPen);

		QBrush mojsBrush(lbr.color());
		painter.setBrush(mojsBrush);

		painter.drawRect(16,rowY1,width-16-1,rowY2-rowY1);

		// Check for any changes in the registers.
		if (lastPC != cpu->GetPC())
		{
			for (int i = 0, n = cpu->GetNumRegsInCategory(0); i < n; ++i)
			{
				u32 v = cpu->GetRegValue(0, i);
				changedCat0Regs[i] = v != lastCat0Values[i];
				lastCat0Values[i] = v;
			}
			lastPC = cpu->GetPC();
		}

		painter.setBrush(currentBrush);
		if (i<cpu->GetNumRegsInCategory(category))
		{
			QString regName = cpu->GetRegName(category,i);
			textPen.setColor(0x600000);
			painter.setPen(textPen);
			painter.drawText(17,rowY1-3+rowHeight,regName);
			textPen.setColor(0xFF000000);
			painter.setPen(textPen);

//.........这里部分代码省略.........
开发者ID:18859966862,项目名称:ppsspp,代码行数:101,代码来源:ctrlregisterlist.cpp


注:本文中的QScrollBar::setMinimum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。