Namespaces
Variants
Actions

Archived:Como usar uma QProgressBar

Jump to: navigation, search
Archived.png
Aquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated.

Este trecho de código demonstra como usar uma QProgressBar Qt.

Dados do artigo

Testado com
Aparelho(s): Emulator

Compatibilidade
Plataforma(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition

Artigo
Palavras-chave: QProgressBar,QSpinBox
Tradução:
Última alteração feita por hamishwillee em 11 Oct 2012

Contents

Varias funções

  • Este trecho de código mostra uma porcentagem na barra de progresso, indicando o que já foi completado até o momento.
bar->setVisible(1);
Qtprogress2.jpg
  • Esta propriedade é usada para inverter a direção do atual progresso, na barra.
bar->setInvertedAppearance(1);
SpinInvert.JPG
  • Esta função é usada mudar a orientação da barra de progresso (vertical e horizontal).
bar->setOrientation(Qt::vertical);

Progressbar1.JPG

Pré-requisitos

  • Baixe e instale a versão atual do Qt, segundo as instruções deste artigo.


Arquivo de cabeçalho(Header)

#ifndef PROGRESSBAR_H
#define PROGRESSBAR_H
 
#include <QtGui/QWidget>
#include "ui_progressbar.h"
#include <QProgressBar>
#include <QSpinBox>
#include <QVBoxLayout>
 
class progressbar : public QWidget
{
Q_OBJECT
 
public:
progressbar(QWidget *parent = 0);
~progressbar();
 
private:
QWidget* win;
QVBoxLayout* layout;
QProgressBar* bar;
QSpinBox* spin;
};
 
#endif // PROGRESSBAR_H


Código fonte

#include "progressbar.h"
 
progressbar::progressbar(QWidget *parent)
: QWidget(parent)
{
win = new QWidget(this);
win->setWindowTitle(("LCD Number"),this);
layout = new QVBoxLayout(this);
bar = new QProgressBar(this);
spin = new QSpinBox(this);
spin->setMaximum(99);
spin->setMinimum(0);
bar->resize(200,25);
bar->setOrientation(Qt::Horizontal);//Orientation can also be vertical
bar->setRange(0,99);
connect(spin, SIGNAL(valueChanged(int)), bar, SLOT(setValue(int)));
layout->addWidget(spin,Qt::AlignCenter);
 
layout->addWidget(bar,Qt::AlignCenter);
win->setLayout(layout);
win->showMaximized();
}
 
progressbar::~progressbar()
{
// No need to delete any object that has a parent which is properly deleted.
}


Conclusões

  • Aqui você pode modificar o valor do spinbox, gerando uma alteração na barra de progresso.

Qtprogress1.jpg

  • Captura de tela com 40% do progresso

Qtprogress2.jpg

Exemplo

This page was last modified on 11 October 2012, at 04:14.
164 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved