PDA

View Full Version : QString class global



prophet0
30th December 2011, 16:57
how can i access a QString ill show my code on how im trying to do this

bottom.h




extern QString *buttonFV;


then in bottom.cpp



while(iconmodel->query().next())
{
buttonFV = iconmodel->query().value(0).toString(); // String I'm Tring to get the value from in a slot

emit next_DoStyle();


}


SLOT in bottom.cpp



void ttmbottom::do_Style()
{

QString bttnPath;// = QApplication::applicationDirPath();
bttnPath = "/home/dev/ttm/directory/icon/";
bttnPath += buttonFV; // trying to use it here !!!!!



}


if anyone can help me solve this issue i always have problems trying to use the data i have stored

Lesiok
30th December 2011, 17:51
Why You don't define slot as

void ttmbottom::do_style(QString);
and then emit signal as

emit next_DoStyle(iconmodel->query().value(0).toString());

prophet0
30th December 2011, 18:33
Sorry would you be able to show a little example as im testing it with mine and cant seem to get it working

Lesiok
31st December 2011, 07:42
First show definition of class ttmbottom. Then I will be able to modify.

ChrisW67
31st December 2011, 08:40
The code as presented should not compile. Regardless of which compilation unit contains buttonFV, buttonFV is a pointer to a QString not a QString. Line 2 of the first and line 6 of the second bottom.cpp are trying to use pointer to a QString as if it were a QString.

prophet0
3rd January 2012, 18:27
The code as presented should not compile. Regardless of which compilation unit contains buttonFV, buttonFV is a pointer to a QString not a QString. Line 2 of the first and line 6 of the second bottom.cpp are trying to use pointer to a QString as if it were a QString.

any work arounds you suggest ?

ChrisW67
3rd January 2012, 21:00
You cannot "work around" invalid C++ syntax: you just have to correct it. Either make buttonFV an actual QString, or change everything that uses it to expect a pointer to a QString.

prophet0
4th January 2012, 15:36
ok thanks ill change everything to expect a pointer