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

  • SEARCH
  • Home
  • 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 8312553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:12:15+00:00 2026-06-08T20:12:15+00:00

What I’m trying to accomplish: Create 2 classes that inherit QVBoxLayout simply to set

  • 0

What I’m trying to accomplish:

Create 2 classes that inherit QVBoxLayout simply to set up each class with a series of different objects.

e.g.:
Class 1 (inherits QVBoxLayout), has QLabels to show an appointment and those labels set up with this->addWidget(labels);

Class 2 (inherits QVBoxLayout), has QLineEdits (and so on) to edit an appointment and those objects are also set up with this->addWidget(lineedits);

Is it possible to have a QWidget class then switch between these 2 layouts by calling this->setLayout(class1_object); and this->setLayout(class2_object);?

Or how would you suggest the swapping of the active objects on the widget (when clicking the edit button on the view-part or the save button on the edit-part)?

Simply use object->setShown(false);?

  • 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-06-08T20:12:17+00:00Added an answer on June 8, 2026 at 8:12 pm

    IMO, it’s easier to use QTabWidget here.
    Make a QTabWidget with 2 tabs. On Tab1, put your labels. On Tab2, put your edits. Call Tab2 something like “Edit the appointment”. Now, use the currentChanged() slot for catching the tab switching.

    If saving edits should be simple, all you will need to do is just to copy the edited data from edits to labels, and vice-versa.

    If saving requires more than that, e.g. you want a confirmation dialog, you can permit the user to change back to Tab1 until some condition is met:

    void MainWindow::on_tabWidget_currentChanged(int index)
    {
        //if the user is trying to go back to Tab1 (where the labels are)...
        if(index == 0)
        {
             //...and if user didn't accept something, we just return him to the current tab
             //It's probably a good idea to tell him what went wrong, too :P
             if(!userAcceptedSaveDialog())
                 ui.tabWidget.setCurrentIndex(1);        
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

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.