Issue with QLabel rotation on Qt4.8 & WinCE6.0



  • I seem to be stuck with an issue where i'm unable to rotate text appropriately on WinCE6.0 device using Qt4.8. Device is supposed to be in portrait mode (default landscape) for this instance of application. This requires rotating most of the widgets by 90 degrees.

    In order to do this with QLabel, i'm re-implementing it's QPaint even with "some" success.

    What i'm getting when i'm using

    QPainter.rotate(90.0)
    

    is:

    T
    E
    S
    T

    What i want to get instead is individual character rotate by 90.0 degrees as opposed to the whole text. So it would look like this instead:

    0_1473242564369_upload-3e6c1034-e5db-4004-ac08-3129c883f9c8

    Any advice on this would be much appreciated. Thanks!



  • Anybody?


  • Qt Champions 2016

    Hi
    Image upload is sadly broken at the moment so your
    image is not visible to others. (must upload to other place)

    So its unclear for me what the wanted text should look like. :)

    My guess is :

    void VertLabel::paintEvent(QPaintEvent *)
    {
    QPainter painter(this);
    painter.setPen(Qt::black);
    painter.rotate(90);
    painter.drawText(QPoint(0,-15), "abcdefgh" );
    }

    if this draw differently on WinCE6.0, it might not be supported or bugged.
    This is on win 10, Qt 5.7.



  • Hi mrjj,

    Thanks for your reply. You're right, what you have in your attached image is what i'm expecting my text to be, but unfortunately it's draws as in my first example. I've tried your suggested code with the same results, so it looks like a bug...

    Do you've any other ideas how i might achieve similar result, any of the following worth a try?

    • Try it with a different widget type, not a QLabel?
    • Try rotating QPixmap of QLabel after drawing (already tired this with no success, but still not entirely sure it was 100% correct). In essence, would text drawn using "drawText" routine would be treated as QPixmap after it has been draw on the QLabel face or would it remain text all the time?

    Appreciate your reply!


  • Qt Champions 2016

    hi
    Drawing non rotated text should work.
    But let us just test it :)

    (note. fast code. not pretty)

    void VertLabel::paintEvent(QPaintEvent*) {
    QPainter painter(this);
    QPixmap pix(width(), height());
    QPainter pp(&pix);
    pix.fill();
    pp.setPen(Qt::black);
    pp.drawText(QPoint(0, 25), "abcdefgh" );
    painter.rotate(90);
    painter.drawPixmap(0, -50, pix);

    }



  • @mrjj

    Hi mrjj,

    Sorry for delayed response, was away from work for few weeks.
    Just tried your solution and it's working like a charm!

    Thanks for your help on this, much appreciated!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.