How to remove the GtkTreeView sorting arrow? - c++

I need to remove the sorting arrow from a column header. This can be done by calling set_sort_indicator(false) on the column.
The arrow isn't displayed, but the space for it seems to still be reserved. If the title of the column is big enough to fill all the header, the last part is clipped (where the arrow should be).
Is there a way to make the title fill the whole header?

This seems to be a bit weird in GTK+. I downloaded and read through relevant parts of the GtkTreeViewColumn's code, and it seems to use this logic:
if (tree_column->show_sort_indicator ||
(GTK_IS_TREE_SORTABLE (model) && tree_column->sort_column_id >= 0))
gtk_widget_show (arrow);
else
gtk_widget_hide (arrow);
Where arrow is the widget holding the arrow. This seems to indicate that the arrow widget is always packed into the horizontal box that makes up the column's header, and then just hidden (not removed) if it's not supposed to be visible. That will mean it's still there in the box, occupying space and causing the label to be clipped.
I'd recommend searching through the GTK+ bugtracker for an issue about this, and if none is found, create one.

Ok, so I've submitted a bug report to gtk. They said that it is not an issue and it won't be fixed.
I've looked on other graphical toolkits (windows, qt) and their implementation is different, but this doesn't seem to matter to the guys in the gtk team.

Ok you can use set_clickable method to the the column you don't want it to have an arrow
then use signal_connect to the clicked signal and bind it to a function which will use get_sort_column_id to get the current sort order then apply the reverse sort order using set_sort_column_id.

Related

Qt QCombobox popup inconsistent position

I have searched far and wide and cannot find anything online about my issue even though it seems rather trivial, and i feel like there's just something I'm missing, so I apologise if the answer is apparent.
However, when I use a QComboBox in Qt, When I click on it instead of dropping down like I want it to, it shows the popup with the current selected item as the origin. If that doesn't make sense this is what I am referring to:
It shows the popup starting at the current selected item where the button is. I just want it to drop downwards like any other normal combobox! How can i Achieve this? If i make it editable it drops down exactly how i want it, but i don't want it to be editable!
Does anyone know what's up?
Edit:
I am running Windows 10

How to check if all of the many fields are filled? [C++, VS 2015, Windows Form]

I'm making Windows Form project in C++ using Visual Studio 2015 and I have to check if all the TextBoxes are filled in and RadioButtons checked before I let the user go to the next panel. The problem is that when the "Next" button is clicked, I need to check all these fields one by one (textbox->text=="" etc.) and that makes really long "if".
Is there any other easier (or just better looking) way?
It might be stupid question, but I'm still learning.
You can find many solution for this.
For example:
You can catch change in all the text boxes and use a numeric variable big enough to be used as bitmap with bit for each box, You start it when all bits are set. In the on_change, if the box is empty set the bit for the corresponding box, if not clear it.
Now you can enable the next button only if the bitmap variable is zero.

Two column TPopupMenu to list shortcuts right aligned

Using Borland/CodeGear/Ebarcadero C++ Builder 2009. Is it possible to show shortcuts (or other text), right aligned in a second column in a TPopupMenu ?
For instance:
[image] Open File ctrl-O
[image] Close File ctrl-W
[image] BlahBlah ctrl-B
etc.
If so, how ?
I checked the break property on an item, but the results is not exactly what I want, since items are selectable on their own, instead of the complete line. Also it's not drawn that nicely.
Your feedback appreciated.
A menu item can have an image (see the TMenuItem.ImageIndex property), and can have a shortcut assigned (see the TMenuItem.ShortCut property). The VCL will automatically draw those elements for you, exactly as you have shown.
By default, they are a little squished together. You can use the TMenuItem.OnMeasureItem event to extend the Width:
If you still do not like the way the default drawing looks, or you want different text than the ShortCut to appear on the right side, you will have to owner-draw the menu items yourself (see the TMenuItem.OnDrawItem and TMenuItem.OnAdvancedDrawItem events), then you can make the menu items appear however you want.

Remove horizontal divider line from mfc wizard

I have a mfc wizard in which I implemented code for re-sizability. There's a horizontal divider line at the bottom of the wizard dialog, as shown by the red arrow in the picture, which I need to get rid of.
Since I don't know the ID of that line, I haven't included it in my resize code. Because of that, when I resize the wizard, the line keeps messing up the dialog.
It would be a great help if the ID of the divider or a method to remove it can be found.
Thanks.
On my machine (Win8.1) the ID is 3026, as shown with Spy++; have a look if it's the same on yours and/or other machines. Otherwise you could still enumerate all windows and look for the one with the STATIC window class. Then just DestroyWindow() that.
That said, I don't think the line is the issue here; the issue is that your dialog isn't redrawing itself properly. And I speculate that this is caused by it assuming a fixed size. Wizards aren't meant to be resized (see http://msdn.microsoft.com/en-us/library/windows/desktop/bb774544%28v=vs.85%29.aspx and http://msdn.microsoft.com/en-us/library/windows/desktop/bb246463%28v=vs.85%29.aspx). Even if you destroy the line, other content you will put there is going to be invalidated incorrectly as well, I think.
Maybe you can work around it by manually invalidating or playing with various clip related windows styles. However the real answer is 'don't do that'.

Qt: How to show icon when item selected

I have a QListWidget containing items which have icons and when the items are selected the icon is just highlighted out. Is there a way to prevent this? I can't use stylesheets because it's for an embedded application and including them takes up too much space.
thanks
I suppose when you say "Highlithed out", you mean that the icon colors don't render well when the line is selected, and therefore, you can't see properly the icon...
Maybe you could consider using a different icon when the item is selected. It's possible to do so by specifing a mode to your icon.
Example :
QIcon MyIcon(":/images/foo");
MyIcon.addFile(":/images/bar", QSize(...), QIcon::Selected);
You can easily make a try in QtDesigner and see the results...
Hope it helps a bit !
Certainly, drawing on a black-and-white screen presents its challenges.
It sounds like you just want to change the appearance of the interface, not any functionality. If this is the case, a QItemDelegate-derived class (or QStyledItemDelegate) is almost certainly what you want. In particular, the drawDecoration function looks like it is used to draw an icon, and the style options should include whether it is selected. The simplest fix would be to override that function, set the selected flag in the options to false, then pass it up to the parent's function.