[SOLVED]Please review this small code
-
HERE is the code for a slider that changes the value of the progress bar. The problem is, at a time only one progress bar works . Though both of them are connected, niether of them disconnected.
@#include “mainwindow.h”
#include “ui_mainwindow.h”
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);
connect(ui->horizontalSlider,SIGNAL),ui->progressBar,SLOT));
ui->setupUi(this);
connect(ui->horizontalSlider,SIGNAL),ui->progressBar_2,SLOT));}
MainWindow::~MainWindow()
{ delete ui;
}@ -
your code is damaged.. put it between '@' symbols
Anyway you dont need to call
@
ui->setupUi(this)@twice. Remove the second one
-
thanks a lot _rmn.
I am a beginner, started with Qt yesterday itself. Can You pls explain me the reason , how does calling twice affect it?? -
I think "Qt DOC":http://qt-project.org/doc/qt-4.8/ could be a good start for you.
Edit:
You should avoid upper case in the title of the post. -
If you look inside setupUI method, then you can see that in its generated code all widgets from your .ui file is newly created. So all you do with it inside your code before calling setupUi method second time is lost. Also call setupUi method twice and more is not memory safe.
Read more at: http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html -
Hi,
The form created using QtDesigner is stored as an xml file, setupUi() is a function that creates the actual instances of the widgets that you created using the QtDesigner.
The title of your post should be more specific/related to the problems/errors you are getting.
Kindly read "Forum Help":http://qt-project.org/wiki/ForumHelp guidelines for more information.
-
Thanks a lot for the helpful information.
-
[quote author="rajatgupta431" date="1355396444"]
I am a beginner, started with Qt yesterday itself. [/quote]Welcome to the forum and have fun with Qt :) Please when you post your source mark is as code by clicking the code button or by just surrounding it with @
-
[quote author="leon.anavi" date="1355398574"]
Welcome to the forum and have fun with Qt :) Please when you post your source mark is as code by clicking the code button or by just surrounding it with @
[/quote]
Sure,I ll do as said :)
-
[quote author="Luca" date="1355397400"]
Edit:
You should avoid upper case in the title of the post.[/quote]
Done :)