Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Text improperly scaled in QLineEdit wrapped in a QGraphicsProxyWidget when QGraphicsView is scaled
Forum Updated to NodeBB v4.3 + New Features

Text improperly scaled in QLineEdit wrapped in a QGraphicsProxyWidget when QGraphicsView is scaled

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 3.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • napajejenunedk0N Offline
    napajejenunedk0N Offline
    napajejenunedk0
    wrote on last edited by
    #1
    1. Create a QLineEdit.
    2. Put it in a QGraphicsProxyWidget and include the proxy in a QGraphicsScene, or just call addWidget from the QGraphicsScene instance.
    3. Create a QGraphicsView and set its scene to be the scene you have just created.
    4. Now scale the view using: QGraphicsView::setScale(qreal sx, qreal sy).
    5. Notice that on Windows and Linux the text looks good, but on Mac OS X it is displayed pixelated.

    Windows and Linux:

    text: scaled (rasterized at actual resolution)
    QLineEdit's border: magnified (pixelated)

    Mac OS X:

    text: magnified (pixelated)
    QLineEdit's border: magnified (pixelated)

    A sample project is attached to the following bugreport:
    https://bugreports.qt.nokia.com/browse/QTBUG-21783

    1 Reply Last reply
    0
    • napajejenunedk0N Offline
      napajejenunedk0N Offline
      napajejenunedk0
      wrote on last edited by
      #2

      Found a workaround:

      1. Set the QLineEdit's font to have pixel size equivalent to the height of the QLineEdit widget. Do this in the showEvent function of the class that wraps the QGraphicsView, QGraphicsProxyWidget and QLineEdit or in the showEvent function of a QLineEdit subclass. Save this pixel size to a member variable.
      2. Detect the view scaling.
      3. In the detection function set the pixel size of the QLineEdit's font to be equal to the cached font pixel size ( point 1) ) multiplied by the uniform view scale ( make the view scale uniform ).
      4. Scale down the proxy widget by 1.0 / scale.
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved