ich bekomme regelmäßig 3 Fehlermeldungen:
1. setHost
2. setUser
3. get
nur kann ja nicht alles schiefgehen
hier die Klasse, die in meinem Prog QHTTP verwendet
Code: Alles auswählen
// ****************Splash******************** \\
splashup::splashup(QWidget *parent) : QWidget(parent)
{
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
QPixmap splashbmp(":/splash.png");
QLabel *splashimg = new QLabel(this);
splashimg->setBackgroundRole(QPalette::Base);
splashimg->setScaledContents(true);
splashimg->setPixmap(splashbmp);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(splashimg);
layout->setMargin(0);
layout->setSpacing(0);
setLayout(layout);
url.setUrl("http://www.webcd.eu/produkte2.xml");
fileInfo.setFile(url.path());
fileName = "/tmp/"+fileInfo.fileName();
httpobj = new QHttp;
httpobj->setHost(url.host(), url.port() != -1 ? url.port() : 80);
if (!url.userName().isEmpty())
httpobj->setUser(url.userName(), url.password());
connect(httpobj, SIGNAL(requestFinished(int, bool)),
this, SLOT(httpRequestFinished(int, bool)));
connect(httpobj, SIGNAL(dataReadProgress(int, int)),
this, SLOT(updateDataReadProgress(int, int)));
connect(httpobj, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
connect(httpobj, SIGNAL(done (bool)),
this, SLOT(done(bool)));
connect(httpobj, SIGNAL(stateChanged(int)),
this, SLOT(stateChanged(int)));
progress = new QProgressBar;
layout->addWidget(progress);
progress->setOrientation(Qt::Horizontal);
progress->setTextVisible(true);
status = new QLabel;
status->setText (tr("k.a."));
layout->addWidget(status);
isready=true;
mainwindow = new amway;
mainwindow->setFixedSize(900, 720);
file = new QFile(fileName);
if (!file->open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("File Open"), tr("An Error occurred."));
delete file;
file = 0;
return;
}
}
void splashup::download()
{
httpobj->get(url.path(), file);
}
void splashup::httpRequestFinished(int requestId, bool error)
{
if(!error)
{
QMessageBox::information(this, tr("HTTP"), tr("An Error occurred."));
}
}
void splashup::updateDataReadProgress(int bytesRead, int totalBytes)
{
progress->setRange(0,totalBytes);
progress->setValue(bytesRead);
}
void splashup::readResponseHeader(const QHttpResponseHeader &responseHeader)
{
}
void splashup::readResponseHeader(bool error)
{
if(!error)
{
QMessageBox::information(this, tr("HTTP2"), tr("An Error occurred."));
}
else
{
}
}
void splashup::done(bool error)
{
if(!error)
{
QMessageBox::information(this, tr("HTTP"), tr("An Error occurred."));
}
else
{
//file->close();
isready=false;
hide();
mainwindow->show();
}
}
void splashup::stateChanged(int statushttp)
{
if(statushttp=0)
{
status->setText (tr("Unconnected"));
}
if(statushttp=1)
{
status->setText (tr("Host Lookup"));
}
if(statushttp=2)
{
status->setText (tr("Connecting"));
}
if(statushttp=3)
{
status->setText (tr("Sending"));
}
if(statushttp=4)
{
status->setText (tr("Reading"));
}
if(statushttp=5)
{
status->setText (tr("Connected"));
}
if(statushttp=6)
{
status->setText (tr("Closing"));
}
}
bool splashup::ready()
{
return isready;
}