Nominate our 2022 Qt Champions!

Two textEdits both were called with setFont( sameFont) , yet one has larger font than the other ... but still they are the same font family..

  • Hi , I have 2 textEdit windows , each have been given the same information on setting their fonts

    ui->textEdit->setFont(m_Font);    ui->textEdit_2->setFont(m_Font);

    note: the m_Font had been switched from points over to pixels to work with my display


    When I check to see what type of font each textEdit has , I get the following ...

    ui->textEdit->font() family:Sans Serif | ui->textEdit_2->font() family:Sans Serif
    ui->textEdit->font() pixelSize:21 | ui->textEdit_2->font() pixelSize:21
    ui->textEdit->font() bold:0 | ui->textEdit_2->font() bold():0
    Yet the fonts show up as different sizes in the two textEdits , what could be going on here ? Anyone have an idea ?

  • Hi, if you look in Control Panel, Display, what's the size setting? If it's set not to 100% but instead 125% or 150%, then those kinds of inconsistencies I think can occur.

  • Hi, I am not programming on a windoz machine at the moment. It is a Linux box ... However I am not sure if I can find similar settings to make one of the textEdits a different scale than the other. If i did it somehow while coding, I sure don't know where or when... :)

  • Hi,

    have you changed the m_font pixelSize property before to assign it to both QTextEdit (or after)? Did you changed something between the 2 assignment?

  • Hi , m_font pixelSize is set in the constructor , it is also modified by reading a value in from a couple of different Xml files ...So it does get modified. I think that they must be losing sync in values somewhere.. Been debugging without qdebug since the target machine won't run it. So I am using other more primitive methods. Well, About time this code got a little UML anyhow I suppose !

  • Well I cleaned up the code a bunch anyhow.. Still got some strange responses .I put the textedits into an update function so that when one font gets changed over to a new one (the 2nd textbox also gets modified.) No where else in the code are the fonts Set. There is a font merge that might be affecting things... On the search goes

  • Well It was about time I cleaned up that code anyhow. Alot of it was experimental as I was trying out textEdit, textCursors, documents and all textedit related goodies..seems I did have a mergecharformat in there , as well ...

  • Hi,

    could you show some code that reproduce the issue??

Log in to reply