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 6251123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:33:17+00:00 2026-05-24T13:33:17+00:00

I’m developing a GUI application in Qt. This is my first GUI application and

  • 0

I’m developing a GUI application in Qt.

This is my first GUI application and I’m not very experienced and still have to wrestle with some more advanced aspects of C++ and Qt framework.

The application is pretty simple, featuring a main window and some dialogs where the user configures settings and presses a button, and the program performs a (quite complex) calculation, giving the result somewhere on the UI.

Now, I’m having a problem. I put all my calculation data (which is static and loaded from resources) and logic to a separate class. I create an instance of this class and of the UI classes. Now, the problem is how to access the members of the data/logic class from a UI class? Say there’s a QStringList sitting in the Logic class, and I want a certain dialog to access this list and present it to the user, without making any copies of it in memory?

I understand this is probably a very basic C++ question (Qt not even relevant), but hey not everyone’s a programming wizard. Thanks for any hint or help!

  • 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-24T13:33:18+00:00Added an answer on May 24, 2026 at 1:33 pm

    There are several ways of doing this so your question is valid.

    1. Your GUI class can be derived from your logic class. Not the typical approach but it depends on how your application is designed. One major drawback is that the GUI would have to stay in the same thread as logic if you don’t want to involve locking-mechanisms in your logic class. Often you want two objects to run in separate threads such that heavy computation does not freeze the GUI (see Qt’s QObject thread affinity).

    2. Your GUI class can hold a pointer to your logic class and/or vice-versa. It may also be a reference for convenience if your logic class exists before the GUI class and survives it. Then you can pass the reference to the constructor of the GUI class and you never have to test whether a pointer is valid.

    3. Your GUI class can access data members via getters/setters or directly, if you want to make them public or simply define your GUI class as a friend class to the Logic class. Even if you use getters, they can return const references, so no copy involved. Qt classes like QStringList also have their own reference counting, copy-on-write mechanism that avoids copies.

    4. Your GUI class can emit signals and the Logic class can receive them. See Qt signal/slot mechanism. It is very nice for events like a "Start computation" button. Signals have two advantages: (a) they can go across threads, however if the receiver is not the main loop it gets a little bit more tricky; (b) the objects don’t have to see each other (no pointer passing), you can connect the signals to slots anywhere in your program where you have see both objects at once.

    Typically you will use a mixture of 2 and 3: Use getters to read the data from Logic class that is presented to the user. Use Signals to provoke action or manipulate data (user makes a choice, Logic class has to react).

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

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.