Hi,
Im newbie in QT and C++...
Im trying to add widgets (label and progressbar) to statusbar and found 2 ways (I think...):

1- create the widgets and add them to statusbar in main class. this works OK!! but I dont know how to update the progressbar within mainwindow class... I stopped here...

2- I see in this forum: create the widgets and add them to statusbar in mainwindow class (maybe is more simple to access to update values) but i doesnt work... I stopped here....

Anyone please assist me?

I post the code of my second option (may be the best???):

Mainwindow.h :
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5. #include <QUrl>
  6. #include <QMap>
  7. #include <QProgressBar>
  8. #include <QHBoxLayout>
  9. #include <QLabel>
  10.  
  11.  
  12. namespace Ui {
  13. class MainWindow;
  14. }
  15.  
  16. class MainWindow : public QMainWindow
  17. {
  18. Q_OBJECT
  19.  
  20. public:
  21. explicit MainWindow(QWidget *parent = 0);
  22. ~MainWindow();
  23.  
  24. private:
  25. void init();
  26. void createStatusBar();
  27.  
  28. Ui::MainWindow *ui;
  29. QMap<QString, int> Globales;
  30. // QFrame status_frame;
  31. // QHBoxLayout layout;
  32. QLabel *box;
  33.  
  34. private slots:
  35. void on_Web_loadProgress(int progress);
  36. void on_Web_urlChanged(QUrl);
  37. void on_Web_loadStarted();
  38. void on_BtnLogin_toggled(bool checked);
  39. };
  40.  
  41. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp :
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <QWebSettings>
  4. #include <QProgressBar>
  5. #include <QLabel>
  6. #include <QStatusBar>
  7. #include <QProgressBar>
  8.  
  9.  
  10. MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
  11. {
  12. // Rutinas de Inicio
  13. createStatusBar();
  14. init();
  15.  
  16. ui->setupUi(this);
  17.  
  18. }
  19.  
  20. MainWindow::~MainWindow()
  21. {
  22. delete ui;
  23. }
  24.  
  25. void MainWindow::on_BtnLogin_toggled(bool checked)
  26. {
  27. if (checked) {
  28. //login
  29. Globales["Estado"] = 0;
  30. ui->Web->load(QUrl(ui->txtURL->text()));
  31. }
  32. else{
  33. //logout.
  34. ui->Web->load(QUrl("http://..."));
  35. Globales["Estado"] = 0;
  36. }
  37. }
  38.  
  39. void MainWindow::on_Web_loadStarted()
  40. {
  41. // here I intent to show the progressbar
  42. //ui->statusBar->pBar->show();
  43. }
  44.  
  45. void MainWindow::on_Web_urlChanged(QUrl newurl)
  46. {
  47. ui->LogNav->setTextColor(QColor("blue"));
  48. ui->LogNav->append(newurl.toString());
  49. }
  50.  
  51. void MainWindow::init()
  52. {
  53. //Fijar seteos del browser
  54. QWebSettings::globalSettings()->setAttribute(QWebSettings::AutoLoadImages, false);
  55.  
  56. }
  57.  
  58. void MainWindow::on_Web_loadProgress(int progress)
  59. {
  60. // Here I intent to update the progressbar
  61. }
  62.  
  63. void MainWindow::createStatusBar()
  64. {
  65. // status_frame = new QFrame();
  66. // status_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  67.  
  68. // layout = new QHBoxLayout(status_frame);
  69. // layout->setContentsMargins(0, 0, 0, 0);
  70.  
  71. bar = new QProgressBar();
  72. bar->setMaximumHeight(10);
  73. bar->setMaximumWidth(100);
  74. bar->setValue(80); //for testing
  75.  
  76. box = new QLabel("Check Mode");
  77.  
  78. // Two Options: Which is right ???
  79. //ui->statusBar->addWidget(bar);
  80. //ui->statusBar->addWidget(box);
  81. statusBar()->addWidget(bar);
  82. statusBar()->addWidget(box);
  83. }
To copy to clipboard, switch view to plain text mode 

Best regards!!!