本文整理汇总了C++中QScrollBar::setSliderPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollBar::setSliderPosition方法的具体用法?C++ QScrollBar::setSliderPosition怎么用?C++ QScrollBar::setSliderPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollBar
的用法示例。
在下文中一共展示了QScrollBar::setSliderPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveDrag
/**
* @param x x coordinate
* @param y y coordinate
*/
void CanvasView::moveDrag(int x, int y)
{
const int dx = _dragx - x;
const int dy = _dragy - y;
if(_isdragging==DRAG_ROTATE) {
qreal preva = qAtan2( width()/2 - _dragx, height()/2 - _dragy );
qreal a = qAtan2( width()/2 - x, height()/2 - y );
setRotation(rotation() + qRadiansToDegrees(preva-a));
} else if(_isdragging==DRAG_ZOOM) {
if(dy!=0) {
float delta = qBound(-1.0, dy / 100.0, 1.0);
if(delta>0) {
setZoom(_zoom * (1+delta));
} else if(delta<0) {
setZoom(_zoom / (1-delta));
}
}
} else if(_isdragging==DRAG_QUICKADJUST1) {
if(dy!=0) {
float delta = qBound(-2.0, dy / 10.0, 2.0);
doQuickAdjust1(delta);
}
} else {
QScrollBar *ver = verticalScrollBar();
ver->setSliderPosition(ver->sliderPosition()+dy);
QScrollBar *hor = horizontalScrollBar();
hor->setSliderPosition(hor->sliderPosition()+dx);
}
_dragx = x;
_dragy = y;
}
示例2: notificationClicked
void ChatWindow::notificationClicked() {
if (parentWidget()->isMinimized()) {
parentWidget()->showNormal();
}
if (isHidden()) {
show();
}
// find last mention
int messageCount = ui->messagesVBoxLayout->count();
for (unsigned int i = messageCount; i > 0; i--) {
ChatMessageArea* area = (ChatMessageArea*)ui->messagesVBoxLayout->itemAt(i - 1)->widget();
QRegularExpression usernameMention(mentionRegex.arg(AccountManager::getInstance().getAccountInfo().getUsername()));
if (area->toPlainText().contains(usernameMention)) {
int top = area->geometry().top();
int height = area->geometry().height();
QScrollBar* verticalScrollBar = ui->messagesScrollArea->verticalScrollBar();
verticalScrollBar->setSliderPosition(top - verticalScrollBar->size().height() + height);
return;
}
}
Application::processEvents();
scrollToBottom();
}
示例3: showErrorMessage
void KeErrorText::showErrorMessage(const QString &str, int error)
{
QString htmlStr = QTime::currentTime().toString() + " : " + str;
stringToHtmlFilter(htmlStr);
switch (error){
case EMsg_Info:
stringToHtml(htmlStr,QColor(Qt::black));
break;
case EMsg_Warning:
stringToHtml(htmlStr,QColor(Qt::darkMagenta));
break;
case EMsg_Error:
stringToHtml(htmlStr,QColor(Qt::red));
break;
}
QTextCursor cursor = this->textCursor();
cursor.movePosition(QTextCursor::End);
this->setTextCursor(cursor);
this->insertHtml(htmlStr);
this->insertHtml("<br>");
QScrollBar* scrollbar = this->verticalScrollBar();
scrollbar->setSliderPosition(scrollbar->maximum());
}
示例4: moveDrag
/**
* @param x x coordinate
* @param y y coordinate
*/
void CanvasView::moveDrag(int x, int y)
{
const int dx = _dragx - x;
const int dy = _dragy - y;
if(_isdragging==ROTATE) {
qreal preva = qAtan2( width()/2 - _dragx, height()/2 - _dragy );
qreal a = qAtan2( width()/2 - x, height()/2 - y );
setRotation(rotation() + qRadiansToDegrees(preva-a));
} else {
QScrollBar *ver = verticalScrollBar();
ver->setSliderPosition(ver->sliderPosition()+dy);
QScrollBar *hor = horizontalScrollBar();
hor->setSliderPosition(hor->sliderPosition()+dx);
}
_dragx = x;
_dragy = y;
// notify of scene change
sceneChanged();
}
示例5: printLine
void DashBoard::printLine( const QString& line )
{
infoViewer->append( line ) ;
QScrollBar *scrollbar = infoViewer->verticalScrollBar();
scrollbar->setSliderPosition(scrollbar->maximum());
}
示例6: tabFont
void
TabsView::showTab( TabsItem *tab )
{
if( tab )
{
QString tabText = tab->getTabData();
if( tabText.length() > 0 )
{
tabText.replace( "\n", "<br></br>", Qt::CaseInsensitive );
QFont tabFont( "monospace");
tabFont.setStyleHint( QFont::Courier );
tabFont.setStyleStrategy( QFont::PreferAntialias );
tabFont.setWeight( QFont::Normal );
tabFont.setPointSize( QFont().pointSize() );
QFont headingFont( "sans-serif" );
headingFont.setPointSize( tabFont.pointSize() + 2 );
headingFont.setStyleHint( QFont::SansSerif );
headingFont.setStyleStrategy( QFont::PreferAntialias );
headingFont.setWeight( QFont::Black );
QString linkColor = The::paletteHandler()->palette().link().color().name();
QString textColor = The::paletteHandler()->palette().text().color().name();
int headingWeight = 600;
QString htmlData = "<html>";
htmlData += "<body style=\"font-family:'" + tabFont.family() + "';";
htmlData += "font-size:" + QString::number( tabFont.pointSize() ) + "pt;";
htmlData += "font-weight:" + QString::number( tabFont.weight() ) + ";";
htmlData += "color:" + textColor + ";\">";
// tab heading + tab source
htmlData += "<p><span style=\"font-family:'" + headingFont.family() + "';";
htmlData += "font-size:" + QString::number( headingFont.pointSize() ) + "pt;";
htmlData += "font-weight:" + QString::number( headingWeight ) + ";\">";
htmlData += tab->getTabTitle();
htmlData += " (" + i18n( "tab provided from: " ) + "<a href=\"" + tab->getTabUrl() + "\">";
htmlData += "<span style=\"text-decoration: underline; color:" + linkColor + ";\">";
htmlData += tab->getTabSource() + "</a>";
htmlData += ")</span></p>";
// tab data
htmlData += tabText + "</body></html>";
// backup current scrollbar position
QScrollBar *vbar = m_tabTextBrowser->nativeWidget()->verticalScrollBar();
int scrollPosition = vbar->isVisible() ? vbar->value() : vbar->minimum();
m_tabTextBrowser->nativeWidget()->setHtml( htmlData );
// re-apply scrollbar position
vbar->setSliderPosition( scrollPosition );
}
}
}
示例7: 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
}
}
示例8: onScrollAfterResize
void SimpleMessageStyle::onScrollAfterResize()
{
for (QMap<QWidget*,WidgetStatus>::iterator it = FWidgetStatus.begin(); it!= FWidgetStatus.end(); ++it)
{
if (it->scrollStarted)
{
StyleViewer *view = qobject_cast<StyleViewer *>(it.key());
QScrollBar *scrollBar = view->verticalScrollBar();
scrollBar->setSliderPosition(scrollBar->maximum());
it->scrollStarted = false;
}
}
}
示例9: moveDrag
/**
* @param x x coordinate
* @param y y coordinate
*/
void EditorView::moveDrag(int x, int y)
{
const int dx = dragx_ - x;
const int dy = dragy_ - y;
if(isdragging_==ROTATE) {
qreal preva = atan2( width()/2 - dragx_, height()/2 - dragy_ );
qreal a = atan2( width()/2 - x, height()/2 - y );
setRotation(rotation() + (preva-a) * (180.0 / M_PI));
} else {
QScrollBar *ver = verticalScrollBar();
ver->setSliderPosition(ver->sliderPosition()+dy);
QScrollBar *hor = horizontalScrollBar();
hor->setSliderPosition(hor->sliderPosition()+dx);
}
dragx_ = x;
dragy_ = y;
// notify of scene change
sceneChanged();
}
示例10: onStdout
void MainWindow::onStdout()
{
char buf[256];
ssize_t read;
do {
read = ::read(pipefd[0], buf, 256);
ui->plainTextEdit->setPlainText(ui->plainTextEdit->toPlainText().append(QByteArray(buf,read)));
} while (read>0);
QScrollBar *sb = ui->plainTextEdit->verticalScrollBar();
sb->setSliderPosition(sb->maximum());
}
示例11: moveDefinicio
void Main::moveDefinicio(QEvent *event)
{
int type = event->type();
int step,pagestep;
QScrollBar *bar;
bar=ui.definicio->verticalScrollBar();
step=bar->singleStep();
pagestep=bar->pageStep();
if (type == QEvent::User+Auxiliar::KeyDown()) {
bar->setSliderPosition(bar->sliderPosition()+step);
}
else if (type == QEvent::User+Auxiliar::KeyUp()) {
bar->setSliderPosition(bar->sliderPosition()-step);
}
else if (type == QEvent::User+Auxiliar::KeyNextPage()) {
bar->setSliderPosition(bar->sliderPosition()+pagestep);
}
else if (type == QEvent::User+Auxiliar::KeyPrevPage()) {
bar->setSliderPosition(bar->sliderPosition()-pagestep);
}
}
示例12: CreateProposalPayToEntry
CreateProposalPayToEntry *CreateProposalDialog::addEntry() {
CreateProposalPayToEntry *entry = new CreateProposalPayToEntry(this);
entry->setModel(model);
ui->entries->insertWidget(0, entry);
connect(entry, &CreateProposalPayToEntry::removeEntry, this, &CreateProposalDialog::removeEntry);
// Focus the field, so that entry can start immediately
entry->clear();
entry->setFocus();
ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint());
QCoreApplication::instance()->processEvents();
QScrollBar* bar = ui->scrollArea->verticalScrollBar();
if (bar)
bar->setSliderPosition(bar->maximum());
return entry;
}
示例13: MultisigAddressEntry
MultisigAddressEntry * MultisigDialog::addPubKey()
{
MultisigAddressEntry *entry = new MultisigAddressEntry(this);
entry->setModel(model);
ui->pubkeyEntries->addWidget(entry);
connect(entry, SIGNAL(removeEntry(MultisigAddressEntry *)), this, SLOT(removeEntry(MultisigAddressEntry *)));
updateRemoveEnabled();
entry->clear();
ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint());
QScrollBar *bar = ui->scrollArea->verticalScrollBar();
if(bar)
bar->setSliderPosition(bar->maximum());
return entry;
}
示例14: SendCoinsEntry
SendCoinsEntry * MultisigDialog::addOutput()
{
SendCoinsEntry *entry = new SendCoinsEntry(this);
entry->setModel(model);
ui->outputs->addWidget(entry);
connect(entry, SIGNAL(removeEntry(SendCoinsEntry *)), this, SLOT(removeEntry(SendCoinsEntry *)));
connect(entry, SIGNAL(payAmountChanged()), this, SLOT(updateAmounts()));
updateRemoveEnabled();
entry->clear();
ui->scrollAreaWidgetContents_3->resize(ui->scrollAreaWidgetContents_3->sizeHint());
QScrollBar *bar = ui->scrollArea_3->verticalScrollBar();
if(bar)
bar->setSliderPosition(bar->maximum());
return entry;
}
示例15: prompt
void ConsoleWidget::prompt(QString text)
{
QString text2 = text;
moveCursor(QTextCursor::End);
handleColor(); // change to default color
// add space because it looks better
text2 += " ";
// go to new line if line isn't empty
emptyLine();
insertPlainText(text2);
m_lastLine = "";
// if we have trouble keeping viewport
QScrollBar *sb = verticalScrollBar();
sb->setSliderPosition(sb->maximum());
m_prompt = text2;
}