Qt: huge scrollable sub-menu loses items - css

Updated to add:
I have fixed this, after a fashion. First, I tried calling MySubmenu -> clear() and rebuilding the sub-menu whenever the parent menu was clicked. Surprisingly, this didn't work. So I brought in the big guns: delete MySubmenu followed by MySubmenu = new QMenu (MyMainWindow) and rebuilding the sub-menu. It works now, without much noticeable delay. So I'm happy, I suppose.
Original question:
I have a sub-menu with about 1000 items in it (it's a list of C functions in a debugger). By default, Qt displays the sub-menu in columns, but this sub-menu is too big to fit on the screen, and I have no way to access the items that don't fit.
So I made the sub-menu scrollable, using a style sheet:
MySubmenu -> setStyleSheet ("* { menu-scrollable: 1 }") ;
It looks like this:
Note the scroll buttons at the top and bottom. But now if I select an item (PopRecordLength in this example), then the next time I open the sub-menu, all items above PD_DecryptCommand have disappeared:
The scroll button at the top has disappeared (the little line you can see is an underscore from what used to be the previous item.) And if I scroll down to the bottom, there is a large empty space. The total size of the sub-menu hasn't changed, but the items above PD_DecryptCommand have disappeared off the top, and I can't access them with mouse or keyboard.
However...I have just discovered, in the process of preparing this post, that if I click on this large empty space, the sub-menu disappears, but the next time I open it, it has been restored to its original state. So there is a work-around. But it's not very friendly.
Is this a bug in Qt? Or am I not setting the style sheet correctly?

Probably, since you have so many items that the menu takes the whole screen height, when you select an item its height increases a bit and the scroll button on top gets out of view.
I would try to connect the triggered signal of the menu with the update slot in order to get the menu repainted every time an action has been triggered
connect(MySubmenu , SIGNAL(triggered(QAction*), MySubmenu , SLOT(update()));
You could also try changing the max-height of your menu (max-height stylesheet property).

I'm sorry, not really an answer to your question, but do you really think it's a good idea to put 1000 items into a menu? The usability of this is just terrible. You should find a better way to present so many actions to the user, such as alphabetical submenus ("p" -> "PopRecordLength", "PopShort" ... ). This would also solve your problem with the menu.

Related

How to prevent QMenu from going out of the main window

I have a QMenubar inside QMainWindow. I have set it to be displayed on the right corner using setCornerWidget. But the menu items are going out of the main window. How can I prevent the menu to be displayed within the window?
I have already tried menu->setLayoutDirection(Qt::RightToLeft) which is giving me a mirror image of the current menu display as seen below, but that does not look good to me. Is there a way to keep the direction from Qt::LeftToRight and still be able to contain the menu inside the window?

Drop scroll using select in last line of the table

I made a custom dropdown. In the last line of the table, scroll is created when dropdown is open. I need to scroll to see dropdown elements. I do not want this.
I want you to open up the body of the dropdown or enlarge the body. How can I do it?
Document is already enlarged by enlarged content/element, scroll shows that. You need only scroll to view entire enlarged element, f.e.:
elmnt.scrollIntoView(false);
Real problem (using react) is that should be done after change state and rendering enlarged element.
I probably would use setTimeout called from setState callback. It's quite common way to be sure it's called after updating state/view. You'll find examples on SO.

Single menu item on click moves down but keep other menu items in place

I have a link/button that moves down when clicked but upon doing so all other menu items move as well. How does one keep the other items in place while the button move down?
http://www.llcinpa.com/ click on Form Your LLC Now
the easy answer is this:
#menu-main-nav li{margin-left:28px !important}
this way no matter what, you'll keep your margins, which are the root of the problem

ASP.NET AJAX Toolkit ReorderList with more items than fit on the page

I have a ReorderList on my page and it works just great, but...
Now, I have almost 100 items that I'd like to be able to reorder and they flow off the page, even at 8pt. When dragging, the page does not scroll as I approach the bottom (or the top) so I have to drop my item, scroll down, then drag some more. When I drag and drop in Word, as I approach the bottom of the window, the window scrolls so I can move to where I want to drop.
Alternately, it would be fine with me to have the items show up in multiple columns - their width would allow at least 3 columns. But none of the CSS solutions I have found which allow a <ul> to have multiple columns seem to work as they require multiple <ul>s which I don't think I can do with the ReorderList control.
Any ideas?
Here is an idea: Check if the left mouse button is being hold down, and also check for the position of the pointer on the page. If the coordinates are down at the bottom of the page at a position that you think is down enough for the page to be scrolled, then you could use the window.scrollBy() Method, and stop it when the Mouse button is released. You could also set a bool value when a Reorder item is clicked and while the button is down, and set it to false when it is released, and again the same idea, check for the position of the pointer.
Sample window.scrollBy()
Good luck!

adobe flex datagrid selectable columns

I'm trying to make a Flex (Advanced)DataGrid component with some mechanism where the user can toggle the visibility of the columns. I've crudely implemented this by reading in the columns into the right-click menu, and when a column name is selected here, the visibility is toggled. It works, but it's not the most elegant solution.
Specifically, I'm trying to emulate the "datagrid" that Mozilla Thunderbird uses to display emails. Here is an image:
In the upper right, there is an icon over the scroll bar. If there is no scrollbar, the icon remains in the same place. When clicking the icon, it opens up a menu that shows all the possible columns, with the visible ones having a check mark next to them, like this:
Also, the scroll bar always appears under this button, never "pushing" it over into it's own column.
I'd like to re-create this in Flex. I believe the menu part and creating a column with a button headerRenderer is easy enough. But I can't figure out how (if at all possible) to do this with the scrollbar, because the scrollbar always seems to be "its own column". Any ideas or help would be appreciated. Thank you.
Ian
One dirty solution comes to mind. Create a component based on Canvas, then add an AdvancedDataGrid by overriding createChildren. Override updateDisplayList as well and add a button like the one in Thunderbird to the upper right of the Canvas. This will cause the button to appear over the DataGrid. Problemo solved?

Resources