You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, December 20th 2011, 7:03am

How to set spinner image for qstackwidget ???

Hi All,
I am trying to add a spinner to QStackwidget, i am having 5 frame pages in the stackwidget with 5 buttons below in a seperate frame and when i press the 1st button it should load the spinner image in the frame page and similarly for all others.. In my application,when i give these below codes i am not able to get it.

QAnimationLabel* spinner = new QAnimationLabel(":images/spinner-24x24.gif", this);
spinner->start();

QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(spinner, 0, Qt::AlignCenter);
QFrame* frame = new QFrame;
frame->setLayout(layout);
setCentralWidget(frame);

It's not accepting the SetCentralWidget(frame); and i could not find any solution for this.
Answers will be highly appreciated!!!

Thanks in Advance and Regards,
Naufal.A

2

Tuesday, December 20th 2011, 7:20pm

you get an error with that code? not surprising since it doesn't compile. I think you have not shown us the whole picture.... :evil: X(

what do you mean by 'it'? what do you mean by 'not accepting? compiler error? runtime error? where is the error message? what class is the code you have shown us in?

YET ANOTHER example of the kind of post that I wrote my sig for. Another example of someone who didn't read the guidlines
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

This post has been edited 1 times, last edit by "Amleto" (Dec 20th 2011, 7:27pm)


3

Wednesday, December 21st 2011, 5:22am

Hi Amleto,
I am extremely sorry for the code!!! I will explain you clearly again this whole thing!!
I am having a stackwidget with 5 frames displaying the list widget and 5 buttons below the stackwidget frame.. If i select the 1 button page1 list is displayed.,.. similarly for all the other pages the list gets displayed. I need to add a loader(.gif image) into each page when i press the button. I am not able to display that in that frame in the stackwidget.I tried the above code to show it in the central layout but could not do it.
Is there any solution for bringing the loader in-between the loading page time???

Sorry Again and Thanks in Advance and Regards,
Naufal.A

4

Wednesday, December 21st 2011, 8:11am

you're sorry about the code but havent changed it or shown any more. what is a loader? Of course gif does not load anything...

post a compilable example.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

5

Wednesday, December 21st 2011, 8:53am

Hi Amelto,
I mean loader page should be visible in-between the time of button pressed and loading the page!!!
I had downloaded the API from one link and tying to use them in my application!!!
The same concept as it follows in it.. i am trying to keep 5 buttons below and when i press it should load when clicked.
In that i am using stackwidget with listwidgets placed above it.When i give that code which was given earlier i could not port them into my app

Thanks in advance and Regards,
Naufal.A
naufalahad has attached the following file:

6

Wednesday, December 21st 2011, 5:45pm

back to this question then - why do you have NO stacked widget in your code?

and why do your pages (assuming you have some somewhere) need to load/take so long to load?

the gif comes up when you press start, so what is the problem?
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

7

Thursday, December 22nd 2011, 4:39am

Hi Amelto,
I had kept the qstackwidget in the ui design part and have not used in the code.Centerpart is qstackwidget and at the bottam we have 5 buttons.

I have divided the pages into 2 frames,say 80-20.. 80% for displaying the listwidget,.,. this listwidget are placed over the each page of the stackwidget to display the listview and bottam area for displaying the 5 buttons.,when i click on each button one of the frames get loaded.
Whenever i click a button the loading image(.gif image) should start and whenever the page has been loaded the image should disappear.
This is what i am trying.,

My problem is i have tried loading this image from mainwindow.cpp to load this page. it works fine, but when i tried in homescreen where we have placed the stackwidget and bottom with buttons.
i couldn't manage to bring the loading image. as said i have 5 buttons at the bottom when i click any one of the button i used to display the image, as follows

void homescreen::onbutton1clicked()
{
QAnimationLabel* spinner = new QAnimationLabel(":images/spinner-24x24.gif", this);
spinner->start();

QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(spinner, 0, Qt::AlignCenter);
QFrame* frame = new QFrame;
frame->setLayout(layout);
setCentralWidget(frame);
.................................
...................................
.................................
//code which i used to load the details which i get from the server to the screen.
.........................
............

and here i finally stop the .gif file animation loading once the details as been shown in the screen.
}

this is the prob i am facing.

This post has been edited 1 times, last edit by "naufalahad" (Dec 22nd 2011, 5:17am)


8

Thursday, December 22nd 2011, 9:52am

so post your ACTUAL code with the ACTUAL problem.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

9

Thursday, December 22nd 2011, 10:11am

Hi Amelto,
This is the actual code and actual prob....

10

Thursday, December 22nd 2011, 12:35pm

since when is

Source code

1
...................................


a compilable c++ statement/expression? I give up.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

11

Thursday, December 22nd 2011, 12:46pm

Hi,
This is my click event slot for a button:

void Homescreen::setPage5()
{
ui->framePages->setCurrentIndex( 4 );

QAnimationLabel* spinner = new QAnimationLabel(":images/spinner-24x24.gif", this);
spinner->start();

QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(spinner, 0, Qt::AlignCenter);
QFrame* frame = new QFrame;
frame->setLayout(layout);
ui->framePageCalls->set(frame);

MainWindow::identification.append("checkin");
QByteArray postData("");
QList<QPair<QByteArray, QByteArray> > headers;

postData = postBody.toAscii();
if (!HttpCommunicator::splitIntoHeaders("", headers)) {
//ui->m_textBrowserResp->setText(tr("Failed to parse HTTP headers."));
return;
}
HttpCommunicator::HttpRequestType requestType = HttpCommunicator::httpRequestTypeForText("POST");
m_httpCommunicator = new HttpCommunicator(requestType,"http://.....", postData, headers, "True");

QEventLoop loopforactivity;
connect(m_httpCommunicator,SIGNAL(finishedRequest()),&loopforactivity,SLOT(quit()));
m_httpCommunicator->makeRequest();
loopforactivity.exec();
QList<QString> Name;
QList<QString> Address;
QList<QString> Distance;
QString name;
QString address;
QString distance;
QString configfile = QApplication::applicationDirPath() + "/config_file.txt";

QSettings setting(configfile, QSettings::IniFormat);
setting.beginGroup("checkin");
const QStringList childgroup = setting.childGroups();
int numberofgroup = childgroup.count();

for (int i=0;i<numberofgroup;i++)
{
QSettings setting(configfile, QSettings::IniFormat);
setting.beginGroup("checkin");
QString index = QString::number(i);
setting.beginGroup(index);
name = setting.value("Name", 4711).toString();
address = setting.value("address", 4711).toString();
distance = setting.value("distance", 4711).toString();
Name.insert( i,name );
Address.insert( i,address);
Distance.insert( i,distance);

setting.endGroup();
setting.endGroup();
}

contenttocheckin(Name,Address,Distance);
}

This is the total code for a single button!!!!!
Here is how i tried the loading image to this button

12

Thursday, December 22nd 2011, 4:02pm

several questions:

Why do you want a new spinner everytime someone clicks the button? Surely you want to start/stop an existing one?
Why do you want a new layout everytime someone clicks the button?

how do I (or anyone else) know what

Source code

1
ui->framePageCalls->set(frame);

does?

why do you start the spinner, but never stop it?

I would suggest you should use a layout that contains 1) your spinner, 2) your stack widget.

you should not be making new widgets every time someone clicks a button to 'change the page'.


YOUR LATEST CODE IS STILL NOT COMPILABLE.

READ MY SIGNATURE.

POST COMPILABLE EXAMPLES.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

13

Friday, December 23rd 2011, 6:11am

Hi Amelto,

This code works fine!!!!!
QAnimationLabel* spinner = new QAnimationLabel(":images/spinner-24x24.gif", this);
spinner->start();
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(spinner, 0, Qt::AlignCenter);
ui->framePageCalls->set(layout);
........

spinner->stop();

Thanks for your help and support!!!

Regards,
Naufal.A