Can anyone please tell me how to create a combobox like following with Gtk (on Linux)? (I already ask this question for win32 API).
A code example or tutorial will be very helpful. I have tried searching this over the internet, but unfortunately documentations/tutorials aren't that much rich for Gtk. Thank you very much.
Regards,
I know how to do this in C, but I'll try to wing it in C++. First of all, use a ComboBox to display your menu, which you will fill using a TreeModel.
Create a TreeModelColumnRecord following the example here; you will need just one Gdk::Pixbuf column to display your line images.
Pass the TreeModelColumnRecord to the constructor of ListStore. Fill your ListStore with Gdk::Pixbuf images of your line patterns, and pass that to the constructor of your ComboBox (ListStore inherits from TreeModel).
Related
I've seen answers for this all over the place but not for non-MFC C++. I already know how to populate a listbox with the contents of a folder - that's not what I want. I need a listbox to have a small folder picker so I can display the contents of the selected item (the files therein) in a separate list box. Again, I know how to achieve all of this except for having a folder picker inside a listbox.
I've looked at all the listbox functions on MSDN and there was only like four or five functions there and none of them seem to do this.
I don't really have any relevant code to post related to this question, so I hope what I have explained here is good enough.
Here's a picture of what I'm trying to replicate:
Thanks!
I'm writing an application using C++ and gtkmm. I made a Gtk stack in it. Now I want to add images instead of text on stackswitcher's buttons. I assume that it's possible because something like this is made in gtk3-demo:
Unfortunatelly the example is made using UI file and I want to do it without UI designer. For now I found this answer:
But it's not very helpful to me. The answer was to use stack.child_set_property but I checked gtkmm documentation for stack and there isn't anything like this for C++. The closest match was Gtk::Stack::child_property_name with adnotation that it returns A ChildPropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes. I suppose this may be the thing i'm looking for, but due to lack of examples I have no idea how to use it.
To sum up: Is anyone able to tell me how to set an image as StackSwitcher's label?
Ok, it seems I've found an answer. I'll post it if anyone needs it in the future:
To change Stack Switcher's text label into image I just needed to do that:
stack->child_property_icon_name(ChildName) = "Icon Name";
How can I sort Items in CListCtrl when the button is clicked?
I made a Dialog based application in MFC.
I put CListCtrl control on my Dialog and set its view style to report type.
I have two columns in this list view.
In here when I clicked the "Sorting" button, it should sort item in the list.
I saw many examples related to this, but none is working for me.
Can some one guide me how to do that?
I assume that you mean the column header when you write "sorting button".
You probably forgot to put this into the message map of your dialog:
ON_NOTIFY(LVN_COLUMNCLICK, IDC_LIST1, OnColumnclickList1)
IDC_LIST1 is the id of the list control which may be different in your code.
Are you somewhat familiar with MFC ? If not, you should follow one of the numerous tutorials available on the net.
I would use a CMFCListCtrl. It is easier, as it as built in sorting functionality and you only have to provide a function with the comparing items algorithm for sorting. I have succeeded using it. You have to override the OnCompareItems on your class derived from CMFCListCtrl. I also recommend you to do a call to EnableMarkSortedColumn(); after your list is created.
The CListCtrl has a SortItems method.
All you need to do is provide your Compare function to it as the parameter.
I don't know much about the contents of your list control so I can't really give you more information.
Please read up on it and extend your question with example code and details of which column needs to be sorted and I can help more.
If the contents of your cells are just text then I usually just return the value of:
return Value1.CollateNoCase(Value2);
There are also lots of tutorials on the Internet. For example:
http://www.codeproject.com/Articles/27774/CListCtrl-and-sorting-rows
In fact, that tutorial suggests us in SortItemsEx. That is what I would use.
http://www.youtube.com/watch?v=r57rO3p1Bcs&feature=youtu.be
So what im trying to do is recreate the gui in the posted video. I have the main window created, and the dialog window. Im brand new to Qt and I have been going over tutorials for all the basics. What I havent been able to find much on is how to go about storing the three values from the "new student" dialog window into the list and how to display the first and last name. I'm also not too sure on how to go about making the values editable.
This is NOT an assignment for any sort of class. I'm trying to learn for my own purposes.
Any sort of strategy for how to link the values from the dialog window to the list, and from the list to main window line edits would be very helpful to me.
A good place to start is the Qt's Model/View introduction.
LE: for a simple way to start look at QListWidget class
I have implemented a list of users in my Qt program, using the model/view principle of Qt. My QListView displays a subclass of QAbstractListModel and so far this works just fine.
Now I would like to customize the display of my user list (display the name on several line, add IP information, and so on: not really relevant, I just want something really custom).
I couldn't find anything in the Qt documentation regarding this: what are my options ?
Note: The items in the list do not need to (can't) be modified, if this can help.
Thank you.
You need to create a new item delegate class to handle the painting. Here is a good answer to a similar question.