Hi Jason, Thanks for the quick reply! Have you used the negative topPadding technique in practice? If yes did you use a fixed value or could you calculate it using QFontMetrics?
Cheers, On Wed, Mar 29, 2017 at 12:36 AM, Jason Allen <[email protected]> wrote: > You are positioning the text and the topmost left edge correctly, but also > consider that depending on a font or character typed, not all characters > take up the full available height. > > Characters like ` ' | / \ and " are sometimes above the height of latin > letters, as are capital-case letters with accents like É vs E, Ñ vs N, or U > vs Ü. See below, using your exact code with additional characters. Note > that `, Ü, and Ñ are indeed flush with/touching the topmost edge: > [image: Inline image 1] > If it's a static label that you're positioning and KNOW won't contain > accents or above-letter-height character, use negative topPadding to nudge > it higher. > > If it's dynamic text that may contain an above-letter-height character, > consider leaving it be as-is, or it might clip on the top edge. > > I hope this helps! > Best regards, > Jason > > > > > *Jason Allen *m: > *703-868-5306 <070386%2085306>*w: www.jasoncaryallen.com > <https://twitter.com/jasonallen127> > <https://www.linkedin.com/in/jasonallen127> > > On Tue, Mar 28, 2017 at 2:51 PM, Shantanu Tushar <[email protected]> > wrote: > >> Hi, >> >> I'm trying to align some text in a Text so that it exactly touches the >> left and top edges of the Text item. With the following- >> >> Rectangle { >> anchors { fill: parent; margins: 5 } >> border { width: 1; color: "red" } >> >> Text { >> anchors.fill: parent >> >> topPadding: 0 >> verticalAlignment: Qt.AlignTop >> text: "HELLO WORLD" >> } >> } >> >> I am able to get the following result- >> >> >> >> As you can see there is still space between the text and the topmost edge >> of the Text. How do I eliminate this space? >> >> Cheers, >> >> -- >> Shantanu Tushar (UTC +0530) >> shantanu.io >> >> _______________________________________________ >> Interest mailing list >> [email protected] >> http://lists.qt-project.org/mailman/listinfo/interest >> >> > -- Shantanu Tushar (UTC +0530) shantanu.io
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
