How to delete the space int QLineEdit



  • Now I'm makeing a programme,this APP look likes a picture,and I can write a note in any place of this picture.for this ,
    

    Iput a QLineEdit on an area where I need note.when I finish note,I hide the QLineEdit,and put a QLabel in sane area,
    the code looks like this

    currentPoint = edits->pos();
    edits->hide();
    labels->moving(currentPoint);
    labels->setText(edits->text());
    

    But there is a question,when the QLabel replace theQLineEdit,the QLabel always moving a little distance to top left corner.Someone tell me,the text of QLabel always appear up against the top of QLabel,but there is a little space between the text of QLineEdit and the top of QLineEdit.
    alt text
    the red line.....

    I try the funtion

    setTextMaria();
    setAlignment();
    

    But they all can't remove this space....

    At last,I only find a way in QPoinf.

    const int MOVINGDIS = 2;
    currentPoint,setX(curentPoint.x() + MOVINGDIS);
    .
    .
    

    After I change the point,the (text of)QLabel and (text of) QLineEdit will display the same place.But this will cause another question,for get the right point ,I use the fixed value(MOVINGDIS),this APP will run in different Embedded system,I can't sure this value will make the APP work on every system.

    1. How can I delete the space.
      2.If can't,the space of QLineEdit(it's wide) is a fixed value or not?

  • Lifetime Qt Champion

    Hi,

    How are you positioning your widgets ?

    What about using QStackedLayout ?


Log in to reply
 

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