在Qt 5.7控制台应用程序中:
import React, { Component } from 'react';
import axios from 'axios';
import {apikey} from './data';
class App extends Component {
constructor(props){
super(props);
this.state = {
title: '',
overview: '',
poster: '',
vote: ''
}
this.getFilm=this.getFilm.bind(this);
}
getFilm(){
const url = `https://api.themoviedb.org/3/movie/550?api_key=${apikey}`
axios.get(url)
.then(data => {
let res = data.data;
console.log(res);
this.setState({
title: res.title,
overview: res.overview,
poster: res.homepage+res.poster_path,
vote: res.vote_average
})
})
.catch(err => {
console.log('error')
})
}
render() {
console.log(this.state.poster);
return (
<div className="main">
<h1> Lets see what you got</h1>
<div name="title">
{this.state.title}
</div>
<div name="overview">
{this.state.overview}
</div>
<div name="poster_path">
<a href={this.state.poster}>Link Movie - Click Here!</a>
</div>
<div name="vote_average">
{this.state.vote}
</div>
<button onClick={this.getFilm}>Get Movie</button>
</div>
);
}
}
export default App;
即。 \ n在直接调试打印中按预期工作,但在调试打印(假设相同的内容)变量时仅被视为两个普通字符。
我在Qt 5.7 Widget应用程序中遇到类似的问题。
我搜索了文档,stackoverflow和Qt Center,但我一直无法发现我做错了什么。
有人可以指点我解决这个问题吗?
答案 0 :(得分:2)
文档给你提示:
通常,QDebug会将字符串打印在引号内,将不可打印的字符打印到其Unicode值(\ u1234)。
要在不进行转换的情况下打印不可打印的字符,请启用noquote()
功能。请注意,某些QDebug后端可能不是8位干净。
VS
将'\ 0'终止的字符串s写入流并返回对流的引用。字符串从不引用或转换到输出,但请注意,某些QDebug后端可能不是8位干净。
解决方案:qDebug().noquote() << "some\nspecial\nchars\n\tincluded"