Qt Quick Controls: currentIndex won't change if model is statically generated on Tumbler + workaround

After a long time I reported a bug to Qt as I found quite unexpected bug from Qt Quick. On Qt Quick Controls 2, if you set model statically in Tumbler component(e.g. model: [2, 4, 6, 7, 10]), everything is shown properly but currentIndex doesn't change at all. For example, even though the screen shows the fifth item, currentIndex is still 0, and onCurrentIndexChanged event doesn't fire at all.

To work around this bug, you may just set a model "dynamically" like as follows:

Components.onCompleted: {

    // do something
    model=[ 1, 2, 3, 4, 5 ] 
    // do something more
}

My check indicates this bug existed since Qt 5.12 or earlier, but nobody seems to have reported this, though I think there must be people using Tumbler like I do...... Well, maybe everyone was too lazy to write a report.

Anyway I reported the bug, and got ticket number QTBUG-85933.

https://bugreports.qt.io/browse/QTBUG-85933

I hope that the bug can be fixed sooner.

Qt Quick Controls: Tumbler에 model을 정적으로 생성하면 currentIndex가 변경되지 않는 문제+우회방안

오랜만에 Qt 버그리포트를 하나 작성했습니다. Qt Quick에서 황당한 버그가 하나 있더군요. Quick Controls 2의 Tumbler에서 model을 정적으로 미리 설정해 두면(이를테면 model: [2, 4, 6, 8, 10]같은 형태로......) 화면은 제대로 작동하는데 내부에서 자기가 어느 데이터를 가리키고 있는지를 찾지 못하는 문제가 있습니다. currentIndex가 죽었다 깨나도 안 변하더군요. 분명히 화면은 다섯번째 아이템을 가리키고 있는데, currentIndex는 0으로 그대로이고, onCurrentIndexChanged 이벤트도 발생을 하지 않는다거나 하는 문제가 있습니다.

이 문제를 우회하려면, model을 동적으로 넣어주면 됩니다. 이를테면 이런 식으로요:

Components.onCompleted: {
    // do something
    model=[ 1, 2, 3, 4, 5 ] 
    // do something more
}

확인해보니 최소한 Qt 5.12부터 있던 버그인데, 아무도 신고하지 않은 것 같더군요. 분명 저처럼 쓸 일이 다들 있을 것 같기도 한데 말이죠...... 아니면, 어쩌면 다들 귀찮아서 말았을지도 모르겠네요. 하여간 신고했고, 티켓 QTBUG-85933를 받았습니다.

https://bugreports.qt.io/browse/QTBUG-85933

이 버그는 언제쯤 해결될 수 있을지 모르겠네요.

아무도 믿지 말라: 디버그 메시지도 믿지 말고.

기계도 거짓말을 합니다. 단지 차이점이라면, 그 거짓말을 시키는건 사람이라는 거죠. 예전과는 다르게 요즘은 대부분의 경우 뭔가 오류나 예외가 발생하면 그 내용을 친절하게 설명해 줍니다. 하지만, 모든 메시지가 다 똑같은 무게를 갖고 있는 것은 아닙니다.

전 직장에서 가장 크게 배운 것이 한 가지 있습니다.
[자바스크립트 콘솔이 내뱉는 메시지를 믿지 말라]
다른 모든 사람들이 메시지만 보고 허둥댈때 저는 그 메시지를 무시하고 직접 파고들어 원인을 찾아낸 경험이 있었습니다. 아무리 봐도 기계어 수준에서는 말이 안 되는 화면이었거든요. 화면에 표시되는 메시지도 사람이 직접 쓴 것이므로, 그 메시지를 쓴 사람이 내용을 잘못 쓰거나 메시지가 나오는 맥락을 잘못 이해하면 컴퓨터는 거짓말을 할 수밖에 없습니다.

뭐, 가끔은 화면 위의 연출 뒤쪽도 봐야 되고, 행간도 읽어야 하는 법이죠.

Trust no one: don't trust debug meesage

Did you know that even a machine can lie to you? The only difference is that it's human that makes the machine lie. Not like long time ago, most of the time you can easily find a good explanation for any error or exception you encounter when you code. However, not all messages are of the same weight.

When I was in my last job, I learned it (a bit) hard way.
[Don't trust message your Javascript console emits.]
While others were trying to find the root cause based on the Javascript console, I intentionally ignored it, since it didn't make sense at all in machine language level. Anyway, the message was  written by a human, so the console had to lie as the program's exception handler says.

Well, sometimes, you have to see beyond the scene, and read between lines.

블로그를 이전합니다

뭐, 이런 작은 변방의 블로그에 관심있으신 분들은 아무도 없으시리라 생각합니다만...... (웃음) 블로그 플랫폼을 블로거에서 dev.to로 옮겼습니다. 새 URL은 아래와 같습니다: https://dev.to/teminian 새로운 거처에서 뵙겠습니...

Popular in Code{nested}