I have a QTableWidget and I want to disable the behavior that a row or column is selected when you click on a row or column header.
Does anyone know how to disable this behavior?
Edit:
The headers need to remain clickable, because the onClick-function is needed.
You might want to disconnect the selectColumn slot from the sectionPressed signal of the header, something along the lines:
disconnect(horizontalHeader(), SIGNAL(sectionPressed(int)),this, SLOT(selectColumn(int)));
QTableWidget::setSortingEnabled(true);
This eliminates the column selection behavior you describe and trades it in for sorting by column!
There are several several ways to do it
The simple way that is not so good :) (and depends on Qt implementations as everything :):
in the table view its horizontal header sectionPressed(int) is connected to table selectColumn(int), so you can simply disconnect them :( (the same sure for vertical header)
You can ipmlement the table view virtual selectionCommand(const QModelIndex&, const QEvent* event) interface and return "no selection" if event is 0 (as it's a 0 then while clicking on header area)
And finally the best and original solution: You can have and then set your own selectionModels both for table and its header (or headers) and re implement the selection behaviors as you want.
tableWidget->setSelectionMode(QAbstractItemView::NoSelection);
This property holds which selection mode the view operates in. SelectionMode
Or maybe you need tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows )
This property holds which selection behavior the view uses.
SelectionBehavior
you can try setting false to the function setClickable
QTableWidget::horizontalHeader()->setClickable(false);
If this works, then you can do the same for [verticalHeader][2]
[2]: http://doc.qt.nokia.com/latest/qtableview.html#verticalHeader "verticalHeader"
I know the answer to this question.
disconnect(yourTableWidget->horizontalHeader(), SIGNAL(sectionPressed(int)),yourTableWidget, SLOT(selectColumn(int)));
for example:
QTableWidgetItem * p_wgtitm = this->ui->tblwSome->item( 0, 0 );
int flags = p_wgtitm->flags();
flags &= ~(Qt::ItemIsUserCheckable | Qt::ItemIsSelectable);
p_tblitm->setFlags( (Qt::ItemFlags)flags );
If Qt for Python is acceptable, it worked for me by doing this:
def setModel(self, model):
super().setModel(model)
self.horizontalHeader().sectionPressed.disconnect()
Apparently the signal was getting connected in setModel. I just disconnected from everything.
Related
how can I enable or disable a CheckButton via code? Is there any simple way like "input pickable true/false" I use with collision shapes? I played around with control focus modes but didn't succeed.
For example: I'd like to have a timer starting when button down / holding down and after a certain time the button shouldn't react at release anymore. Just as if it was never put down in the first place...
There must be a simple command for that, right?
Edit:
Trying
my_button.disabled = true
leads to the error
Invalid set index 'disabled' (on base: 'GDScriptNativeClass') with value of type 'bool'.
It sounds like you're looking for the pressed property.
my_button.pressed = true
The documentation isn't very clear on the usage but it does what you're describing. https://docs.godotengine.org/en/stable/classes/class_checkbutton.html
I have a gridview which takes inputs from a textbox. Multiple values can be added to it. I want to rest the grid. I have tried few codes in the internet. But just clear the grid. When i type the numbers again all the previous numbers appear. I want to remove previous numbers too when i reset the grid. How can i do it?
Here is my back end code
if (grdPolicyDetails.Rows.Count > 0)
{
grdPolicyDetails.Columns.Clear();
grdPolicyDetails.DataBind();
}
I have tried this code too. This too didn't work.
grdPolicyDetails.DataSource = null;
grdPolicyDetails.DataBind();
Are you talking about the History of Browser ? if yes then,
If Clear Gridview Data then,
grdpolicydetails.Controls.Clear();
I need help in check box my problem that when i select any one it gave me message
about my selection but when choose two of check box gave me the last choose of them why and what is the fix please
What is happening is that your Append status is wrong. Instead of appending, you are overwriting the current value. Hence when you choose say two answers, the first is overwritten by the second.
I think the problem is with the syntax of your Append status. Instead of:
Append(Label5.Text =("New Text"));
It should be something like:
Append(Label5.Text).Append("Your new text");
See:
https://msdn.microsoft.com/en-us/library/b4sc8ca8(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
I don't understand how QTable::editCell() should be used. I am trying to do some error checking based on entries made by user in a QTable as mentioned in my another question.
I would like to give user an opportunity to re-edit the cell which has error. For example, if name column entry has some special characters such as '(', the user should be prompted for the error and the control should go back to same cell in edit mode. I tried using QTable::editCell() in my code as shown below.
Table->editCell(row, 0, TRUE);
name = Table->text(row, 0);
However, this doesn't work as expected. The control doesn't stay in the cell at all and obviously the name is not correctly collected. So, my question is how to ensure from within code that a cell of QTable can be edited so that the edited contents can be accessed immediately in next statement (as shown in above code).
Note: I am working with qt 3.3.8 only.
I don't think you can do that. You'll have to go back to the event loop, and wait for one of the signals (like valueChanged(row,col)) to be fired to re-validate the data.
A blocking wait on a GUI object is often not a good approach (except for modal dialogs).
I know I'm a little late here but you should use the following connect statement with your own custom function to do your specific needs such as below. You can also use this method to disable users from entering in special characters within you custom function. That way they wont ever have to correct undesirable characters.
connect(ui->tableWidget, SIGNAL(cellChanged(int,int)), this, SLOT(customFunction(int,int)));
void updateTable
{
//remove invalid characters
}
I think this has to be THE most frustrating thing I've ever done in web forms. Yet one would think it would be the easiest of all things in the world to do. That is this:
I need 2 separate lists of radiobuttons on my .aspx page. One set allows a customer to select an option. The other set does also but for a different purpose. But only one set can have a selected radiobutton.
Ok I've tried this using 2 asp.net Radiobuttonlists controls on the same page. Got around the nasty bug with GroupName (asp.net assigns the control's uniqueID which prevents the groupname from ever working because now, 2 radiobuttonlists can't have the same groupname for all their radiobuttons because each radiobuttonlist has a different uniqueID thus the bug assigns the unique ID as the name attribute when the buttons are rendered. since the name sets are different, they are not mutually exclusive). Anyway, so I created that custom RadioButtonListcontrol and fixed that groupname problem.
But when ended up happening is when I went to put 2 instances of my new custom radiobuttonlist control on my .aspx page, all was swell until I noticed that every time I checked for radiobuttonlist1.SelectedValue or radiobuttonlist2.SelectedValue (did not matter which I was checking) the value always spit back string.empty and i was not able to figure out why (see http://forums.asp.net/t/1401117.aspx).
Ok onto the third try tonight and into the break of dawn (no sleep). I tried to instead just scrap trying to use 2 custom radiobuttonlists altogether because of that string.empty issue and try to spit out 2 sets of radiobuttonlists via using 2 asp.net repeaters and a standard input HTML tag inside. Got that working. Ok but the 2 lists still are not mutually exclusive. I can select a value in the first set of radiobuttons from repeater1 and same goes for repeater2. I cannot for the life of me get the "sets" to be mutually exclusive sets of radiobuttons.
As you have two groups of radio buttons that you want to function as one group of radio buttons, the solution is simple: Make it one group of radio buttons.
The only problem you have then is that the value that you get has the same name from both lists, but that can be solved by adding a prefix to the values so that you easily identify from which list the option comes.
Update: based on the new info posted as an answer. The option I proposed on my original answer corresponds to the 3. You really must consider the following:
Html radio buttons have only 1
built-in mechanism to handle the
exclusivity, which is the name.
You are explicitly requesting a no js solution, so given the above you must manipulate the Ids to achieve it. If you weren't blocking this option I am sure someone would come up with some nice jquery or js library that already supports it.
The option 3 is clearly the less invasive, as you are not forced to affect the actual data, and are not affected by future updates to it.
It's not that much code, just something extra on the List indexes, and some simple thing as:
int? list1Value = null;
int? list2Value = null;
var value = Request.Form["somegroup"];
if (value.StartsWith("List1"))
list1Value = int.Parse(value.Substring(5));
else
list2Value = int.Parse(value.Substring(5));//Assuming List2 as prefix
Original:
I saw your other question, and you just need to use the same group name. Make sure you have different values for all items regardless of the list they come from. A way to achieve this is adding something to the values, like: <%# "List1-" + Eval("ID") %> and modifying the code that reads your Request.Form["yourgroupname"].
I think you should just use RadioButtons instead of RadioButtonLists.
Here's an article that presents a solution to resolve the radiobutton naming bug.
Though this post is dated 1 year ago already, I just read it because I face the same problem.
Currently I have 1 solution using jQuery:
Client side script (you must also include jQuery)
function SetRadio(rb) {
$('input:checked').attr('checked', false);
rb.checked = true;
}
For every radiobutton (which is a listitem in a radiobuttonlist) I add the following on the serverside:
li.Attributes.Add("onclick", "javascript:SetRadio(this)");
For me this works in both IE and Firefox, with 3 radiobuttonlists, without using groupnames.
You can check each radiobuttonlist for a selecteditem/value, or you can extend the SetRadio function so it stores the selected value in a hidden field.
Regards,
M