Is it possible to create multi column combobox by subclassing only its listbox? - mfc

In MFC, is it possible to create multi column combobox by subclassing only its listbox.
In Codeproject and Codeguru websites I got samples only with derived CComboBox with ownerdraw style.

The "list" part of a combo-box control is NOT a list-box control. Apart from this, combo-box controls do not really have "columns", and this means that you cannot store column-level data (there is just one string or "item" per row), and subsequently any solution visually imitating "columns" can only be owner-drawn-based. So, if your app's specs have changed (now requiring column formatting) you should rather consider using another control type. Still, an owner-draw implementation isn't really that hard, esp if you have fixed height items; it shouldn't really require extensive changes to your app, as it concerns this specific control only.

Related

Menu designed for use without mouse. What is the best way to implement?

I'm writing a GUI using QT for embedded system with linux. This device has no mouse. Only display and specific keyboard with keys: up, down, return and 7 number keys.
The software will be used to set some parameters of device and read them (some charts also).
Example of how menu could look:
after OPTION 1 selected
After SUBOPTION 1 selected some table with data is loaded.
Sometimes after selecting option i need to load specific widget and sometimes just another set of options.
I think it is possible to implement custom labels and kind of list widget that aligns them.
I guess it is also possible to use Qt's MVC classes for it. They are highly customizable, but i never made custom views and delegates.
Maybe i just need to create QtListView with stringlist model and apply stylesheet to it so it gets look more like buttons. And based on selection in list load next widget.
Which way is better and why?
Is there any easier ways to accomplish this?
Any ideas would be appreciated.

how to scroll lock first column of a report style listview in C++

I want to lock the first column of a report style listview from scrolling horizontally. I'm programming in C++ using Win32 (no .NET). This functionality does not appear to be available in the standard listview. Any suggestions on how this can be accomplished with C++/Win32? I've seen the suggestion of using a DataGridView in .NET, but I'm not using .NET...
Thanks
About the only thing I can think of is to use two abutting listview controls, one with the single column that never scrolls and the other with all the other columns. Not an ideal solution but there's no way to make the standard listview behave this way.
Alternatively, you could just write your own listview-like control.

how to create ms-access like continuous subforms (widgets) in Qt?

I'm thinking of porting my access application to Qt. I am interested to learn how to do continouos subforms, sub custom widgets for presenting/editing/inserting data from recordset in a verically scrollable non datagrid fashion. Meaning I could put button, label, combo, lineEdit... whatever, for every record.
I like QTableView and delegates. I just don't know if it could be modified to fully emulate access subform.
Sidequestion(maybe the same answer)... how do they DO those continuous forms in access under the hood.
thanks
... not real application data in that example recordset
Qt MVC is probably the best/easiest answer for your question ( http://qt-project.org/doc/qt-4.8/model-view-programming.html ), and with QTableView you should be able to achieve what you want.
Another solution could be: if you have a fix set of column items in every row you could simply design a QWidget with the contents of the row and paste your items (rows) into a QVerticalLayout.
Although I would sugget to try with MVC because that's the preferred way and in this case you could even port it to use QML UI if you want (while you can use the same data classes for the 'backend'). QML is definitely the best approach for (even slightly) animated UIs, and it's mature enough to use it already (it's part of Qt 4.8 and will be the 'star' of Qt 5).

create a scrollbar in a submenu qt?

I have a map application and a submenu which has dynamically added objects (i.e. points on a map) added to the submenu, depending on the layer that is loaded. I have the ability to hide each individual objects (i.e. a point) by clicking on the corresponding submenu item. Is there any way to organize the submenu? When there are a lot of points (i.e. 100) the entire submenu takes up the screen. Can I add a scrollbar to a submenu? I looked in the documentation, but couldn't find anything that support this feature.
From this bug report I was able to find out that you could do the following:
submenu->setStyleSheet("QMenu { menu-scrollable: 1; }");
Works like a charm.
There is no such possibility as far as I know.
Maybe you shouldn't use a sub menu for this but prefer a menu entry that show a Point manager GUI of your own which would have a QListWidget displaying all your points items.
I'm aware that this solution will break a (big?) part of your code but I don't see anything else.
I think you may be able to get the effect you want by creating and using your own QStyle subclass (via QApplication::setStyle()), and overriding the styleHint virtual method to return 1 when the StyleHint parameter passed in is SH_Menu_Scrollable. At least, that works for me when I create large QMenu objects and show them as popup menus.... It may also work for QMenus attached to the menu bar, but I havent tried that.
Whilst it is possible by subclassing the QMenu class to create a custom widget and going from there you're better off looking at a better way to display that information. You'll save yourself time and it'll be much easier for your users to not have to scroll through a big list of items in a small area.

Does MFC have a built in grid control?

First what I want: The ability to display a grid with multiple columns, each cell having a custom render callback. So you might use such a control to display your inventory in a game, or something like the behaviour in Google Chrome where it shows a grid of popular pages you visit.
I've been playing with CListCtrl and while I can get custom rendering ability on each item, I can't get it work with columns - having say 3 items per row. The control has column-related methods but I think these are specifically for the built-in functionality where different attributes of an item are shown automatically in each column... not for providing a generic grid control.
So, does such functionality exist in MFC? If not then I wonder if the easiest approach is for me to actually insert each of the rows as an Item... and then the custom rendering draws the multiple cells in the row, I could also do custom UI to support clicking on the cells.
But what I really want is to be able to create a custom control, and add this as an item to a list - like in Flex for instance - so I/O etc is automatically handled.
Any advice/information welcome...
Dundas has thrown some of its (excellent) components in the public domain. Their Ultimate Grid is available on CodeProject.
I'm not aware of a built-in control, but I think you should take a look at this.
The article is describing in detail the functionality of a fully featured MFC grid control, derived from CWnd, for displaying tabular data.
YOUR_LIST_CONTROL.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_GRIDLINES);
I think it will help you (SetExtendedStyle).
I suggest this one:
https://code.google.com/p/cgridlistctrlex/
very complete