I am aware that Qt has a property browser extension called QPropertyBrowser. But I would like to make my own.
My question is, for the browser in QtCreator (see image below), how is it made?
Do they use a QTreeWidget with a seperate QTreeView and linked
model per category?
Do they use a single model and QTreeView and somehow create a delegate for alternating row colors for different categories? I assume it's this based off the single Property/Value header up the top (that controls the width of all columns together).
I know there is the 'All roads lead to Rome' response, but I'd like to know what the best way is, not just any way (this assumes the way they did it is the best way).
Related
how do I put the time, date and company logo on the top of all my Qt forms?
I don't want to redo this same code in all my classes.
I thought I could create 1 class with a stacked widget for the date, time and logo and then call (add) this to all other classes.
I'm not sure how to do this.
In QML, you would generally put the common code in a base class and subclass it to create children that might have values to certain fields that are different - but the same common fields. I use this technique to generate different modes in the same app that might need slightly different toolbars but the same canvas.
You might want to write the ui code in c++ for widgets, and then go from there.
Another approach might be to set the common values inside a model, and use those common values across the board.
What I want to Achive:
Toggling the appearance of an Item, where the components that describe the appearance are loaded dynamically, but common elements are not loaded multiple times.
Lets say, I have a list of elements with an icon (e.g. cover) and a title (e.g. music title).
When clicked/dragged, it shifts the shape, so additional information can be displayed (e.g. duration, artist, ...).
Finally I have a DropArea, in which I can drop those elements. Here I only want to display the icon.
As I am informed correctly, it is not advisable to have all three forms pre-loaded and only shift the visibility and other parameters of the additional objects, as the first list is a ListView.
Therefore I decided, to create multiple components, and then load them with a Loader.
On the other hand, this leads to some overhead, for I load and unload the Icon, that is common to all the components, each time, the shape shifts.
My solution so far is, to load the image outside of the components, re-parenting it each time, the shape shifts. This however feels odd, and I am not sure, if this might not be the less performing way, compared to the "loading everything at once and resetting visiblity and positioners"-approach
What is the proper way to do this?
For the efficiency aspect, the most performing one should be that only dynamically loads something that is really dynamic, and leaves other things static(or so called declarative). In your app, the icon should be declarative, I think.
Regarding with reparenting, actually re-parenting is quite common in Qt Quick programming, especially within dynamically loading context. The parent in Qt Quick is not the same concept of QObject. It's just visual management (not memory management). That's why you can see Qt Quick even provides ParentChange in State/Transition.
I created a simple form object representing some arbitrary name and value pair:
It's intentionally very simple - any design is to be applied through the CSS styles. Apart from the UI, the form consists of C++ class that handles the data loading and custom property defined in Designer too - the name of the data source (eg. hostname).
So I have two values I need to parametrize:
the Name - the QLabel text
the datapoint - some hostname. This will be later loaded by the C++ class and tell it what data should be loaded
I was Imagine I would be able to create "instances" of my form manually in designer and assign parameters to them. Like in this fictional image:
Don't forget datapoint is the custom dynamic attribute. I am sure the described design can be easily carried out programatically, but I feel like the designer solution will be prettier - provided there's a legit way to do it.
Maybe it's wrong, but the only way I can think of is making your Qt Designer aware of your widget. Something like this.
AFAIK, widget propagation doesn't allow you to edit custom properties without code, so you need a full widget support. My colleagues intentionally do whatever posiible from sources, not IDE& Forms, so that the project becomes more portable, but you are to choose yourself.
I have been creating an interactive webpage. The main part is a SVG map. This map has ~600 text labels and these text labels currently have several classes. A current example is below
<text class="UCWF left base" x="1513.8158" y="733.91864"><tspan x="1513.8158" y="733.91864">Canary Wharf</tspan></text>
In the class attribute "UCWF" is a unique station code. (unique to the station but there is also a rectangle representing the station itself so I cannot move this information to an id tag.) The second entry sets the stying for the station being to the left of the text. The final part says wether it is the upper or lower part of the station name. (Some have two so that they appear over the background)
This already seams like a cumbersome solution and it is about to get worse. To each station I want to add information telling if the station has level access for wheelchairs and if you can take bicycles there. To me the obvious solution would be to add this as data attributes
data-cycle="true" data-wheelchair="false"
However I am only going to use this information to affect the text styling. Selecting a button marked wheelchair will set all stations with no wheelchair access to grey and others black so this naturally seams to belong as a class and styling issue.
So the Key Question is does this functionality belong in styling or data? Are there possible limitations in the future from the choice.
I believe both would work. As background I am new to web coding but am interested in following best practise where possible
From the specification
Custom data attributes are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements.
So, if your're using that information only for styling purposes, is better use the class attribute (or style if you don't want to use separate CSS).
The only possible limitation that comes to my mind is that seeing that piece of code in the future you might think that data-* attributes has some kind of special features not related to style.
The best thing for the window I'm designing would be a table with two rows for each element of an array. I'd have one checkbox and two popups in the first row and the second row would be used for text entry. Based on what I understand of a NSTableView is that's not possible. I looked into a NSCollectionView but I don't have any experience with that so my choices are a standard four-column table or tackle a NSCollectionView. Before I do that I wanted to get the opinions of more experienced Cocoa developers.
Thanks
This is possible using either an NSTableview or an NSCollectionview. The NSTableview way would be to subclass NSTextfieldCell ... take a look at ImagePreviewCell.m in apple's PhotoSearch example.
http://developer.apple.com/mac/library/samplecode/PhotoSearch/
The NSCollectionview way would require less code (you can set just about all of it up in IB), but an NSTableView has stuff (like headers etc) than an NSCollectionview doesn't.