Nikita Pearl Waligwa had been diagnosed with a brain tumor.
The 2016 film was based on the true story of Phiona Mutesi, who took up chess aged nine despite not being in school and went on to compete in international tournaments.
It starred Lupita Nyong’o as her mother and David Oyelowo as her chess teacher.
Waligwa played the role of Gloria, a friend of Phiona who explained the rules of chess to her.
She was first diagnosed with a brain tumor in 2016 and Queen of Katwe director Mira Nair reportedly mobilized people to help fund her treatment in India, with Ugandan doctors quoted as saying they did not have the necessary equipment.
She was given the all-clear in 2017 but last year was found to have another tumor.
Her death was announced on Sunday by Gayaza High School, an all-girls boarding school outside the Ugandan capital of Kampala where Ms. Waligwa had been a student.
“You were a darling to many and we have lost you to a brain tumor at such a tender age,” the high school said on Twitter.
The announcement prompted an outpouring of tributes from some of Ms. Waligwa’s co-stars in “Queen of Katwe,” which was based on a 2011 essay in ESPN The Magazine about a chess prodigy in Uganda who grows up in a slum and wins international competitions. The film starred Lupita Nyong’o and David Oyelowo. It was listed as Ms. Waligwa’s only film credit.
The film she played in was directed by Mira Nair and starred Ms. Nyong’o, an Oscar winner for “12 Years a Slave,” as Phiona’s mother.
“She played Gloria with such vibrancy,” Ms. Nyong’o said on Instagram. “In her real life, she had the enormous challenge of battling brain cancer. My thoughts and prayers are with her family and community as they come to terms with having to say goodbye so soon.”
“Queen of Katwe” was the film debut of both Ms. Waligwa and Ms. Nalwanga.
“We mourn the loss of our beautiful Nikita Pearl Waligwa,” Mr. Oyewolo wrote on Instagram. “She was a ball of light in @queenofkatwemovie and in life. Her battle with a brain tumor was humbling to witness. Her light will live on.”