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. [Solved]Hiding default value of QLineEdit
Forum Update on Monday, May 27th 2025

[Solved]Hiding default value of QLineEdit

Scheduled Pinned Locked Moved General and Desktop
qlineedithide
2 Posts 2 Posters 1.9k Views
  • 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.
  • Y Offline
    Y Offline
    Yatshan
    wrote on last edited by Yatshan
    #1

    Hi
    I have attached text './Projects' to QLineEdit object and I have set place holder "Enter the project path". Now place holder text is not visible but text './Projects' is always kept displaying. My actual requirement is to set default value of './Projects' to qlineedit object (i.e to take this value when user doesn't enter any) and keep on displaying place holder text.

    How can I do this?

    Thank you !!!

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      From the documentation for placeholderText : QString:
      "This property holds the line edit's placeholder text.
      Setting this property makes the line edit display a grayed-out placeholder text as long as the line edit is empty."
      So, setting the text means the place holder text isn't shown any more.
      You can check whether the value is empty before you use it. If it is empty you use your default value.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      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