PDA

View Full Version : QStringList make to be born typedef QStringList



patrik08
2nd June 2006, 11:48
Today I have uncovered that QStringList do not have type and is not
possibel to return



QStringList Href_Gui::GetUserConfig();
{
return this->hrefconfisuser;
}

And to solved this i make ...


typedef QMap<int, QStringList> Userconf;

Userconf res;
res.insert(0,MyOwnQStringList);
if moore .... res.insert(1,MyOwnQStringList);

Userconf res = function();

resultMap::Iterator it;
for ( it = res.begin(); it != res.end(); ++it ) {
QStringList fullrow = it.value();
}


My question how to set a typedef QStringList
and not waste performance? .

wysota
2nd June 2006, 12:02
Today I have uncovered that QStringList do not have type

Could you explain that? QStringList is a QList<QString>.

jacek
2nd June 2006, 12:06
Today I have uncovered that QStringList do not have type and is not
possibel to return


QStringList Href_Gui::GetUserConfig();
{
return this->hrefconfisuser;
}
Many Qt classes have methods that return QStringList without problems. What makes you think that you can't return QStringList?

patrik08
2nd June 2006, 12:09
MINGW say...

\href_gui.cpp:46: error: declaration of `QStringList Href_Gui::GetUserC
onfig()' outside of class is not definition



QStringList Href_Gui::GetUserConfig();
{
return this->hrefconfisuser;
}

i must transform so QStringList > QList??




QList Href_Gui::GetUserConfig();
{
return this->hrefconfisuser;
}

patrik08
2nd June 2006, 12:12
#include <QPointer>
#include <QStringList>

/* typedef QMap<int, QStringList> Userconf; emergency solucion */

class Href_Gui : public QDialog, public Ui::Href_Gui
{
Q_OBJECT
//
public:
static Href_Gui* self( QWidget* = 0 );
Userconf GetUserConfig();
//
protected:
void closeEvent( QCloseEvent* );
//
private:
Href_Gui( QWidget* = 0 );
static QPointer<Href_Gui> _self;
QStringList hrefconfisuser;

//
public slots:
void Acceptvars();

};

jacek
2nd June 2006, 12:17
href_gui.cpp:46: error: declaration of `QStringList Href_Gui::GetUserConfig()' outside of class is not definition
The problem is not with QStringList but with GetUserConfig() method which wasn't declared in class definition.

Change:

class Href_Gui : public QDialog, public Ui::Href_Gui
{
...
public:
...
Userconf GetUserConfig();
...
};
to

class Href_Gui : public QDialog, public Ui::Href_Gui
{
...
public:
...
QStringList GetUserConfig();
...
}; and it should work.

patrik08
2nd June 2006, 12:44
html_edit\href_gui.cpp:41: error: declaration of `QStringList Href_Gui::GetUserC
onfig()' outside of class is not definition
html_edit\href_gui.cpp:42: error: expected unqualified-id before '{' token
html_edit\href_gui.cpp:42: error: expected `,' or `;' before '{' token
mingw32-make[1]: *** [build\.o\win32\href_gui.o] Error 1
mingw32-make[1]: Leaving directory `C:/_current/html_editor'
mingw32-make: *** [release] Error 2

QStringList is not a type! i suppose...


***.h


#ifndef HREF_GUI_H
#define HREF_GUI_H
#include <QStringList>
#include <QActionGroup>
#include <QColorDialog>
#include <QPrinter>
#include <QPrintDialog>
#include <QFileDialog>
#include <QFile>
#include <QTextStream>
#include <QMessageBox>
#include <QTextDocumentFragment>
#include <QTextCursor>
#include <QFileDialog>
#include <QString>
#include <QTextStream>
#include <QFontDatabase>
#include <QTextBlockFormat>
#include <QTextListFormat>
#include <QTextFormat>
#include <QTextList>
#include <QTextCodec>
#include <QByteArray>
#include "href_start.h"
//
/* Save file as href_gui.h */
/* Class Href_Gui Created on Fri Jun 2 11:13:27 CEST 2006 */
//
#include <QPointer>
#include <QStringList>

/* typedef QMap<int, QStringList> Userconf;*/

class Href_Gui : public QDialog, public Ui::Href_Gui
{
Q_OBJECT
//
public:
static Href_Gui* self( QWidget* = 0 );
QStringList GetUserConfig();
//
protected:
void closeEvent( QCloseEvent* );
//
private:
Href_Gui( QWidget* = 0 );
static QPointer<Href_Gui> _self;
QStringList hrefconfisuser;

//
public slots:
void Acceptvars();

};
//
#endif // HREF_GUI_H




***.cpp


#include "href_gui.h"
//
/* Save file as href_gui.cpp */
/* Class Href_Gui Created on Fri Jun 2 11:13:28 CEST 2006 */
//
#include <QCloseEvent>
//
QPointer<Href_Gui> Href_Gui::_self = 0L;
//
Href_Gui* Href_Gui::self( QWidget* parent )
{
if ( !_self )
_self = new Href_Gui( parent );
return _self;
}
//
Href_Gui::Href_Gui( QWidget* parent )
: QDialog( parent )
{
setupUi( this );
hrefconfisuser.clear();
connect(okButton, SIGNAL(clicked()), this, SLOT(Acceptvars()));
}
//

void Href_Gui::Acceptvars()
{
QString te = text_href->text();
QString url = url_href->text();
QString target = target_href->itemText(target_href->currentIndex());
if (te.size() < 1 or url.size() < 1) {
QMessageBox::warning( this, tr( "Error Text!" ),tr("Mettete una url valida o un testo valido!"));
}
hrefconfisuser.clear();
hrefconfisuser.append(te);
hrefconfisuser.append(url);
hrefconfisuser.append(target);
accept();
}

QStringList Href_Gui::GetUserConfig();
{
/* return QString(hrefconfisuser.join("$"));*/
return hrefconfisuser;
}
void Href_Gui::closeEvent( QCloseEvent* e )
{
e->accept();
}

patrik08
2nd June 2006, 12:48
Sorry i not see ->

#41 QStringList Href_Gui::GetUserConfig(); ";"