Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QT data type #18

Closed
CNLYJ opened this issue Nov 4, 2019 · 2 comments
Closed

QT data type #18

CNLYJ opened this issue Nov 4, 2019 · 2 comments

Comments

@CNLYJ
Copy link

CNLYJ commented Nov 4, 2019

Hello, I have no problem in using the C + + standard type. Now I have customized the QT qstring to work, but when I want to use QT's qlist, I can't compile it, and the error "error c2039:" struct_to_str ": not a member of" qlist < T > ", I rewrite the conversion function. This is the" template < typename T >

JsonWriter& convert(const char*key, QList&data) {

x2struct_set_key(key);

this->array_begin();

for (size_t i=0; i<data.size(); ++i) {

this->convert("", data[i]);

}

this->array_end();

return *this;

}

@xyz347
Copy link
Owner

xyz347 commented Nov 4, 2019

try this

template <typename T>
JsonWriter& convert(const char*key, QList<T>&data) {
	x2struct_set_key(key);

	this->array_begin();
	for (size_t i=0; i<data.size(); ++i) {
		this->convert("", data[i]);
	}
	this->array_end();

	return *this;
}

@CNLYJ
Copy link
Author

CNLYJ commented Nov 4, 2019

尝试这个

模板 < 类型名 T>
JsonWriter&convert(const  char * key,QList <T>&data){
	 x2struct_set_key(key); 复制代码

	这个 -> array_begin();
	为(为size_t I = 0 ; I <数据。大小(); ++ⅰ){
		 本 - > 转换(“ ”,数据[I]);
	}
	这个 -> array_end();

	返回 * 这个 ;
}

Thank you for your reply. Sorry, my code is the same as yours. The mistake in the problem is just the writing mistake. I have solved it by myself. In the written function, don't use "&" sign

@xyz347 xyz347 closed this as completed Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants