I'm using PowerBuilder and have a problem with the ( if, or, and ) condition - powerbuilder

what i want if i choosed one of checbox but i don't inputed the text or 'c_ao', then messagebox is displaying
i have tried edit the query, like edit symbol "()" position
if Not IsNull(f_na) or Not IsNull(f_dep) or Not IsNull(f_krd) and IsNull (c_ao) then
messagebox ('Warning','need fill in C_AO')
return
end if
i have
3 checkbox ('f_na','f_dep','f_krd')
1 input text/singelineedit ('c_ao')
my expectation is if i choosed some of checkbox in datawindow, and i don't inputed the input text/singelineedit or 'c_ao' then then messagebox ('Warning','need fill in C_AO') is displaying

Since the first part of your logic is for any of the three checkboxes to be checked you would do this:
IF (f_na.checked OR f_dep.checked OR f_krd.checked) AND ISNULL (c_ao.text) THEN
Messagebox(blah, blah)
END IF
This looks to see if any of the checkboxes have been checked and if so, is there text in the singllineedit control.

Related

setting QCombobox selected text to specific data column when using QTableView

I'm using a QCombobox that is using a QTableView to display a table of data. My code is (mostly) working right now except for a few details. One of them is that when I select a row, the combo box title is updated using the first column and I would like to display data from another column. How do I change that?
I tried overriding the currentText() method but it didn't work, it seems it is not used internally to update the combo box title. Does anyone have the answer?
This is what is happening now. My data is organized in 4 columns, the 3 first are boolean values while the 4th is a string. In this screenshot, I selected the "Data 3" cell. When I select it, that gets displayed on the combobox select field is "true", the value that is present on the first column of my selected row.
What I want to get is this :
I am trying to have the data from the 4th column being displayed on the combobox select field.
I found solution, but it is not the best approach. However try it, maybe it is one way to do this:
QString oldTxt;//somewhere
//...
ui->comboBox->setModel(model);
ui->comboBox->setView(new QTableView);
connect(ui->comboBox->view(),&QAbstractItemView::pressed,[=]() {
oldTxt = ui->comboBox->model()->data(ui->comboBox->view()->currentIndex()).toString();
qDebug() << ui->comboBox->model()->data(ui->comboBox->view()->currentIndex());
//ui->comboBox->setEditText(ui->comboBox->model()->data(ui->comboBox->view()->currentIndex()).toString());
});
connect(ui->comboBox,&QComboBox::currentTextChanged,[=]() {
ui->comboBox->blockSignals(true);
ui->comboBox->setCurrentText(oldTxt);
ui->comboBox->blockSignals(false);
});
Main idea: catch selected by user value and set it as current text. Second connection is necessary because without it comboBox will set another value. Just to prove that it works another code snippet:
connect(ui->comboBox->view()->selectionModel(),&QItemSelectionModel::selectionChanged,[=]() {
ui->comboBox->setCurrentText(ui->comboBox->model()->data(ui->comboBox->view()->currentIndex()).toString());
});
Result:
As you can see, it is value selected by user, not value from first column.
I used here C++11 (CONFIG += c++11 to .pro file) and new syntax of signals and slots, but of course you can use old syntax if you want.
The proper solution was the one pointed out by hank : using QComboBox::setModelColumn().
Hank, I am posting this answer because I couldn't find out how to mark your comment as the accepted answer.

How can I get the checkbox state in a Word form?

I am using a ContentControl checkbox in my MS Word 2013 document (not Excel!). Now I'm trying to check in a formula, whether the checkbox is checked - or not. How can I do that?
Let's assume the checkbox' name is MyCheckbox I tried to check the state using
=MyCheckbox
=IF(MyCheckbox=TRUE; 1; 0)
=IF(INT(MyCheckbox)=1; "YES"; "NO")
But none of them helped me. Any help is appreciated.
You can't reference a checkbox Content Control checkbox from Word's "Field language" using the Checkbox's "name" (i.e. title or tag).
You may be able to do this as follows:
Select the tab of the checkbox that you want to test
Insert a bookmark (let's call it "check1")
Use the following nested field to test the value in your { = } field:
{ IF { check1 } = ccbcc 1 0 }
where you insert a checked checkbox content control directly into the IF field instead of the text "ccbcc"
I don't know of syntax that works with the { = } field's IF function.
However, it is possible that you will run into problems if you make the original checkbox control undeletable. When you do that, copies of the control generated when you execute the { check1 } REF fields also become undeletable, which is something you may also need to consider.
The only other way I know to do this that does not require VBA etc. at runtime is to set the checkbox up as a mapped content control, then use a plain text control mapped to the same element/attribute in the Custom XML part to do the comparison. That will always have a "true" or "false" result once the XML has been populated. So in that case you can compare your plain text control with the text "true". i.e. you still need an IF field with a nested content control, but only one control instead of two, and you don't need bookmarks:
{ IF thetextcontentcontrol = true 1 0 }
(where you insert your mapped text content control instead of "thetextcontentcontrol"
All the { } need to be the special field brace pairs that you can insert on WIndows Word using ctrl-F9.
Try MyCheckBox.Value in place of MyCheckbox.

qt combobox readable but editable

I have at QComboBox some items (added by program - it is a lot added items (about 1000))
So i make combobox editable -> then it is simple to find a correct item. (For example if i want to find item called "My Example" i write in combobox "MY" and i get items which starts from "MY" )
But when i write somethink other than it is in combobox, combobox add this item.
I dont want it, i want only to:
Can select only ITEMS added by Program
Block adding custom items
When i write something like "MY" but dont select item "My Example" because there is "My Example","My Example2"
And press push button to accept my choice - then how to check that i choice item from items added by Program not written and not finished by User?
Set the QComboBox properties to the following:
1. Set setEditable to true.
2. Set insertPolicy to noInsert.
3. Set currentIndex to -1 to make it empty at start.
Then process currectIndexChanged signal which will be sent only when a certain item from the list is chosen.

Combobox displays any LIKE match after User types any characters

I would like an Unbound combobox located in the header of a form to match or filter by any character (s) that a User inputs. I would like those matches only to display in the combobox itself. Once the User selects one of the choices have the form go to that selection and reset the combobox to a complete list.
I tried a parameter query, but that only works once and does not reset. I also looked into LIKE and CONTAINS , but have had no luck.
Use the following in the combo RowSource property:
SELECT [Value for combobox list] FROM tbl WHERE [Value for combobox list] LIKE '*' & forms!MyForm!txtInput & '*'
You need to do cmb.Requery at some stage after a change is made in txtInput. If you do it on the txtInput_OnChange event, you will need to access the Text property of txtInput, so you would need to change the above SQL slightly.
Simplest would be to have a button to be pressed after typing in the filter and putting the Requery method in cmdFilter_Click event

PowerBulder DropDownListBox inside a Datawindow

I have made a DropDownListBox inside a Datawindow.
Upon Item Change, I set and save the Value of the selected item in that DropDown in an INI File.
In my Open Event, I use setitem to Set the saved value in that dropdown.
The problem here is that it doesnt setfocus on that index of the selected item in those dropdown.
I also used, SetRow(), setcolumn(), SetText() just to make the Focusing of the Selected Text.
The problem on this one is I have like 100+ Items. When the chosen value is in the middle, let's say Index#50, the ScrollBar focus is still on the top Index#1, not at Index#50.
Any help? Thanks.
1) Try to play with SetRedraw
dw.SetRedraw(false)
dw.SetItem(...)
dw.SetRedraw(true)
2) Try to use DDDW instead of DDLW. And use DDDW with integer index column. Sometimes builder fails with string "keys"
A) This is so much easier with a DDDW editstyle right in the datawindow. You just do a SetItem( row, column, value) to set the initial value in the dropdown.
B) That having been said, I would not call 100+ items in a listbox "effective UI design". I would evolve that into an editbox, with search-on-type capabilities, like you see in the Google search page.

Resources