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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:29:43+00:00 2026-05-14T04:29:43+00:00

I am writing a GUI based application where I read a string of values

  • 0

I am writing a GUI based application where I read a string of values from serial port every few seconds and I need to display most of the values in some type graphical indicator(I was thinking of QprogressBar maybe) that displays the range and the value. Some of the other data that I am parsing from the string are the date and fault codes. Also, the data is hierarchical.

I wanted to use the model/view architecture of Qt because I have been interested in MVC stuff for a while but have never quite wrapped my brain around how to implement it very well.

As of now, I have subclassed QAbstractItemModel and in the model I read the serial port and wrap the items parsed from the string in a Tree data structure. I can view all of the data in a QtreeView with no issues.

I have also began to subclass QAbstractItemView to build my custom view with all of the Graphical Indicators and such. This is where I am getting stuck. It seems to me that in order for me to design a view that knows how to display my custom model the view needs to know exactly how all of the data in the model is organized. Doesn’t that defeat the purpose of Model/View? The QTreeView I tested the model with is basically just displaying the model as it is setup in the Tree structure but I don’t want to do that because the data is not all of the same type. Is the type of data or the way you would like to present it to the user a determining factor in whether or not you should use this architecture? I always assumed it was just always better to design in an MVC style.

It seems to me like it might have been better to just subclass QWidget and then read in from the serial port and update all of subwidgets(graphical indicators, labels, etc…) from the subclass. Essentially, do everything in one class.

Does anybody understand this issue that can explain to me either what I am missing or why I shouldn’t be doing it this way. As of now I am a little confused.

Thanks so much for any 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-14T04:29:44+00:00Added an answer on May 14, 2026 at 4:29 am

    ** ** – Is this a situation where Qt Model/View architecture is not useful?
    I”m going to say not necessarily – end edit

    I’m not sure I fully understand your question, but let me try.

    First, let’s talk about MVC display pattern. This pattern is all about breaking the program into separate (and hopefully testable) sections that have their own areas of concerns.

    1. The model is data structures that describe your data. I’m sure that there is some statistical data is also present. It is important that the model not know anything about how the data is going to be displayed to the user.
    2. The View is how information is presented to user. It is not suppose to care about how the data is presented for displaying. It is important for this layer to be unaware of how the model gets the data for display.
    3. The control logic is the “glue” to connects the first two items together. This is the layer that holds all the “messy” stuff to make to good user experience. EDIT – Most of what QT calls a “view item” I would probably put in the controller layer.

    But if you do this, then the model and controller layers become very testable.

    With that being said, many of your points are not really related to MVC pattern. You seem to be discussing what is the optimum way to display the data. This is always a problem. And without seeing your app, I’m not really going to try to tell you what is going to look good.

    But by following good MVC pattern design, you can make pretty significant revision to the display without effecting the underling code.

    This being said, I’m dealing with this exact issue right now and this pattern is working well form me. If you go to codeplex.com and search for mvvm (model-view-viewmodel, term used in WPF), you will see a number of projects that use it that you can use to get more information.

    If this is not enough, let me know and I may be able to give you a better answer.

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

Sidebar

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.