小编Jam*_*mol的帖子

c ++:何时使用指针?

在阅读了一些教程后,我得出的结论是,应该总是使用指针来表示对象.但是我在阅读一些QT教程(http://zetcode.com/gui/qt4/painting/)时也看到了一些例外,其中QPaint对象是在堆栈上创建的.所以现在我很困惑.我什么时候应该使用指针?

c++ qt pointers object

16
推荐指数
4
解决办法
2万
查看次数

php:file_get_contents编码问题

我的任务很简单:向translate.google.com发帖请求并获取翻译.在下面的例子中,我使用"hello"这个词翻译成俄语.

header('Content-Type: text/plain; charset=utf-8');  // optional
error_reporting(E_ALL | E_STRICT);

$context = stream_context_create(array(
    'http' => array(
        'method' => 'POST',
        'header' => implode("\r\n", array(
            'Content-type: application/x-www-form-urlencoded',
            'Accept-Language: en-us,en;q=0.5', // optional
            'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' // optional
        )),
        'content' => http_build_query(array(
            'prev'  =>  '_t',
            'hl'    =>  'en',
            'ie'    =>  'UTF-8',
            'text'  =>  'hello',
            'sl'    =>  'en',
            'tl'    =>  'ru'
        ))
    )
));

$page = file_get_contents('http://translate.google.com/translate_t', false, $context);

require '../simplehtmldom/simple_html_dom.php';
$dom = str_get_html($page);
$translation = $dom->find('#result_box', 0)->plaintext;
echo $translation;
Run Code Online (Sandbox Code Playgroud)

标记为可选的行是那些没有输出相同的行.但我得到了奇怪的人物......

??????
Run Code Online (Sandbox Code Playgroud)

我试过了

echo mb_convert_encoding($translation, 'UTF-8');
Run Code Online (Sandbox Code Playgroud)

但我明白了 …

php encoding file-get-contents

8
推荐指数
2
解决办法
4万
查看次数

C++/Qt:画一个插入符号

我正在学习Qt.我刚开始通过继承QAbstractScrollArea从头开始编写文本编辑器.我这样做只是为了练习.但是现在我面临着显示插入符号的问题.我想到的是painter.drawLineQTimer.你能就此提出一些建议吗?我也很高兴听到一些实施阻止和下划线插入的策略.

关闭主题:这是一个错误吗?StackOverflow说这个问题有两个答案,但我只看到一个!

c++ qt paint caret

5
推荐指数
1
解决办法
2159
查看次数

将子组件实例放入活动中

AppComponent

@PerApplication
@Component(modules = arrayOf(AppModule::class))
interface AppComponent {
}
Run Code Online (Sandbox Code Playgroud)

AppModule

@Module(subcomponents = arrayOf(ActivityComponent::class))
class AppModule(private val context: Context) {

  @Provides @PerApplication
  fun provideContext() = context

  @Provides @PerApplication
  fun provideSharedPreferences(context: Context)
      = context.getSharedPreferences("${context.packageName}.preferences", Context.MODE_PRIVATE)

  @Provides @PerApplication
  fun provideMoshi() = Moshi.Builder().build()

  @Provides @PerApplication
  fun provideRetrofit(moshi: Moshi): Retrofit {
    return Retrofit.Builder()
        .baseUrl("https://reqres.in")
        .addConverterFactory(MoshiConverterFactory.create(moshi))
            .addCallAdapterFactory(RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io()))
        .build()
  }
}
Run Code Online (Sandbox Code Playgroud)

ActivityComponent

@PerActivity
@Subcomponent(modules = arrayOf(ActivityModule::class))
interface ActivityComponent {

  fun inject(activity: MainActivity)

  @Subcomponent.Builder
  interface Builder {
    fun activityModule(module: ActivityModule): Builder
    fun build(): ActivityComponent
  } …
Run Code Online (Sandbox Code Playgroud)

android kotlin dagger-2

5
推荐指数
0
解决办法
271
查看次数

标签 统计

c++ ×2

qt ×2

android ×1

caret ×1

dagger-2 ×1

encoding ×1

file-get-contents ×1

kotlin ×1

object ×1

paint ×1

php ×1

pointers ×1