Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7660799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:30:51+00:00 2026-05-31T13:30:51+00:00

this is a question for programming with Qt/C++. I have a combo box with

  • 0

this is a question for programming with Qt/C++. I have a combo box with two items. If current index for selection is 0, then no QLineEdit should be displayed in layout below the combo box. If it is 1, a QLineEdit should appear. It should disappear again if index is 0 again.
Notably, other elements in the layout should not be affected by the change. Values already entered by user in other QineEdit should remain in place.

Is it possible to dynamically modify widget? How did you procede?

Kind regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:30:51+00:00Added an answer on May 31, 2026 at 1:30 pm

    All QWidget objects have a function called hide().

    You can attach a signal to the currentIndexChanged signal of the combo box, and in that function you implement whatever logic you have in mind and invoke the method hide of your QLineEdit.

    The only problem with this approach is that a Qt Widget, when hidden, doesn’t occupy any space on the screen, and this can lead to layout changes (depending on how you’ve programmed your layout, some other widgets can move a bit, for example). To prevent that you can make another Widget appear where the QLineEdit were (perhaps invoking the show() function, and placing the ‘placeholder’ on the same container that the LineEdit was), only to occupy its space and keep it there, or you can use a QStackedWidget add the two Widgets there and change its index.

    I would recommend that you read the following example, it has some useful insight on dynamically changing things: Qt Extension Example.

    Also, when in doubt, take a look in the other examples, they are really well documented and cover a lot of important topics on Qt.

    Good luck with your code 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question may not directly relate to programming. I have noticed that the technology
This question might be naive as I'm new to ColdFusion programming. I have a
I know this isn't strictly a programming question but y'all must have experienced this.
I have two Years experience in C# programming i have a question regarding thread
This question concerns the reflection mechanisms of the java programming language. I have an
I asked this question earlier but regarding another programming languages. Let's say I have
I'm pretty new to Python programming so I have this question: How can I
I have this question since the dawn of my programming career. Is there really
This question is about programming small microcontrollers without an OS. In particular, I'm interested
I posted this question on Reddit Programming and did not get a single response.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.