Can somebody please tell me how to set the cursor position in an MFC CDateTimeCtrl?
After somebody enters a date and presses an "Add" button, I clear my date control contents with m_Date.SetWindowText( "" ); The problem I have is that when tabbing back onto the control, it still shows the year as being highlighted. My date control is of the format DD/MM/YYYY
All I want to to is make the selected text the date (DD) rather than the last field (YYYY) selected.
Ideally, I would like to be able to get a CEdit* pointer to the control's textbox. That way I could use CEdit::SetCurSel() and everything would be fine.
Cheers
I think its safe to say it can't be done. I ended up writing my own control to do the job as have other people as well.
Related
I have an IG display that looks like this without clicking anything else:
Only Supervisor, and Direct Supervisor are editable, and they are both Popup LOV's.
If I double-click the Supervisor data, and immediately type any letter for the Popup LOV search, the data row(s) display shifts to the left like this:
It doesn't matter how wide the window is when I test this. I've been looking for ways to prevent that shift. Do you have any tips to resolve that?
Thank you
I've since learned that this is a known issue, and a bug report was logged: https://community.oracle.com/tech/developers/discussion/4340268/apex-20-1-popup-lov-in-interactive-grid-causing-issue/p1?new=1
I've also noticed that it seems to happen from a single click plus typing to search - not necessarily from a double-click.
Finally, freezing a column or two in place in the IG display appears to prevent the visual shift of the columns.
I am using a QTableWidget and I have a requirement that the user is able to highlight specific text in a cell, but the cell contents should not change if the user accidentally erases or modifies some cell contents. I was thinking that the simplest way to accomplish this would be to just ignore any edits that occur when the user finishes editing a cell. Any ideas how to do this?
Using C++ 98 and QT
You can access the table widget items and modify their properties You want to disable the Qt::ItemIsEditable flag :
QTableWidgetItem* item;
item->setFlags(item->flags() & ~(Qt::ItemIsEditable));
A good way is to set the item prototype before inserting cells into the table. Right after creating the table
const QtableItem* protoitem = table->itemPrototype();
QtableItem* newprotoitem = protoitem->clone();
newprotoitem->>setFlags(item->flags() & ~(Qt::ItemIsEditable));
table->setItemPrototype(newprotoitem);
Now every new cell in the table will have the editable flag disabled. If the user double click it will not open the text edit in the cell.
ps: Do not delete newprotoitem afterwards.
This is late, but for follow-on searches:
The best way to do this is to subclass a delegate (QStyledItemDelegate is the least problematic - no abstract virtuals).
In the delegate, override 'setModelData()' to a stub. The editor will still come up, and you can still change its contents, but the edit won't 'take'. As soon as you leave the cell, it will revert to its original contents.
If you want to prevent the editor from accepting keys (QLineEdit), override 'createEditor()' in your delegate. Call the base class to create an editor, check its type, and then install an event filter on the editor to reject keypress/keyrelease events.
Return the editor in your override.
Works for me, although I did have to const_cast 'this' (to non-const) to install the event filter.
I have a QTableView with 80+ columns displayed in it. The subclass i have created for QTableView allows has functionality for the standard table stuff i wanted e.g order by columns move columns and rows hide column and rows etc.
However the problem i have is the view's focus. lets say you have all the data in the table, you scroll all the way to the right so you are looking at columns 70-80 (assuming 10 columns fit on the screen at once) if i click the header of row 80 (to order by column 80) the table reorders (as expected) however it also jumps the view to the last focused cell (which as far as i can tell is the cell that was last clicked)
What i want to do is not necessarily refocus on the column that was clicked because this might still change the view what im looking for is to just keep the view's focus exactly as it is instead of having it jump back to where the last clicked cell was?
Is there some flag im missing for focus policy or will i need to get the current view and set the view back to that view after mouse clicks that reorder the table and if so how could this be done.
Im aware i have provided no code for this question but it doesnt seem there is any needed since its not a bug im looking to fix more of a feature im unaware of, if you want to see any just comment
EDIT:
Im using a QSortFilterPorxyModel, this seems to get set once (when i call this->setSortingEnabled(true); after the initial call to this on contruction my table model never calls sort again. I have a slot linked to the header clicked signal, and i set the scroll bars to scrollTo() to the index clicked, but i think the sort is happening after this so it does nothing, any idea of what signal are emitted after sorting so i can catch them and then set the view back maybe?
thanks
Before you do your sort, store the current values for where the scroll bars are with
int vPos = yourQTableView->verticalScrollBar()->sliderPosition();
int hPos = yourQTableView->horizontalScrollBar()->sliderPosition();
then after the sort, set it back
yourQTableView->verticalScrollBar()->setSliderPosition(vPos);
yourQTableView->horizontalScrollBar()->setSliderPosition(hPos);
The signals you are looking for are signals of QSortFilterProxyModel inherited from QAbstractItemModel:
layoutAboutToBeChanged()
layoutChanged()
I couldn't reproduce your symptoms by creating a QTableWidget, filling it up with random stuff, and then sorting a particular column. The selected cell stays selected, but does not become visible if it has scrolled off screen.
So the question is, what is causing the behavior you're seeing. It sounds as though scrollTo() is being called by some other function. Since that's a virtual function, I would override it with a pass-through function and see when it's getting called.
I often use select lists with my projects but when it comes to a huge select list, I couldn't find a solution. I need a easy, plug and play solution for solution will be used in a few places.
When you have a select box or text box to be filled from a model data, I want to show user a text box, right side of text box, there should be a button to choice the value. Upon clicking that button, popup or a modal will be opened and I filter all the records and find my value, upon clicking value, modal or popup closes and I get choosen value to form control.
İmagine you have a text box to choose your customer, and among 2500 customer,
PS:don't suggest autocomplete, don't want to accomplish it.
Why don't you look at something like Chozen plugin http://harvesthq.github.io/chosen/. It allows you to easily search large select lists
I created a Combobox with CreateWindowEx. Everything goes well. But I would like to make a final feature: AutoSuggestion. The Combobox is used to do search text in a document, hence at some point, it have items that are the strings a user searched. The AutoSuggestion should be: drop down the list of items, find those items that begin with the string that a user typed in the edit control, but do not select one of them, do not display all other items, and finally do not change select item when keydown or keyup occurs, only highlight the item and select only when a user press Enter. Do you have any idea how to accomplish this task?
It sounds like you want Autocomplete functionality.