I have a form to insert a product on vector. My form is a QT dialog form and I'd like that the space where I insert the date of purchase is blank and when I click on the QDateEdit the current date appears and I can set the date I prefer.
When I add the date to the vector ( both blank and setted date) I show it on QTableWidget. the column of purchase date must show me that value and if it is blank I'd like to be able to set the date I prefer ( after this I have a function to update the info on the vector).
How can I do this? Because on Qdate Class I have nothing that allows me to do this thing (http://doc.qt.io/qt-5/qdate.html).
I have to use qt and c++
thank you, I hope I explained the problem in a good way.
An easy way: use a customized QDateEdit and enable the QCalendarWidget popup, you can customize it using QSS. Example:
When the user sets the new date, just connect the signal dateChanged() whit your own slot and update your data.
Related
How to convert TIBQuery to TIBTable, additionally to display it in DBGrib?
I want to sort data in DBGrid and I used TIBQuery to take sort data from database, and I have problem to convert data from TIBQuery to TIBTable.
Create a VCL C++Builder app - Drop in TIBDatabase, TIBTable, TDataSource and TDBGrid on your form. Make active the TIBDatabase and TIBTable connections. Right mouse click on the TIBTable to add the columns you want to have appear in your TDBGrid. Leave the Column Header text to be the same as the Column Names.
Add the following line of code to the onTitleClick for the DBGrid:
void __fastcall TForm1::DBGrid1TitleClick(TColumn *Column)
{
// set TIBTable's IndexFieldNames property to the column title field name
// this will sort ascending all of the data in the DBGrid
IBTable1->IndexFieldNames = Column->FieldName;
}
If you want to do even more, I suggest that you add a TDataSetProvider and TClientDataSet to your form and then you can do more with your app.
I use plugin Select2 on Apex.
I have scenario like this:
I have three tables: ROOM, MASTER_STUDENT and MAP_STUDENT_ROOM
One ROOM can have many STUDENT
User can select more than one student(with Select2 from MASTER_STUDENT) when create ROOM
When user edit ROOM, previously selected student show in Select2 item(selected item by MAP_STUDENT_ROOM), so user can remove or add more Student
How to achieve point number 4, item Select2 list of values is MASTER_STUDENT but with default selected by MAP_STUDENT_ROOM?
I found this documentation, but i dont know how to apply it.
I'm not familiar with the Select2 plug-in.
Have you considered using the built-in Popup LOV, which since APEX 19.1 now allows multiple selection.
Whether you're using the Select2 plug-in or the built-in Popup LOV, the issue will be the same. You have a form on ROOM, that's trying to take into account an item that isn't part of the ROOM table (its values are stored in MAP_STUDENT_ROOM). The trick is to populate the item correctly during page load so that the item can correctly display the currently assigned students.
How is the item's Source configured? If it's not, set Type to SQL Query (return colon separated value). Assuming you have a primary key item on the page for the room (e.g. P1_ID), enter a query like the following:
select student_id
from MAP_STUDENT_ROOM
where room_id = :P1_ID
Then set Used to Always, replacing any existing value in session state.
This should get the item to display correctly when the page loads. However, you'll still have to figure out how to map the values back to the MAP_STUDENT_ROOM table correctly when the page is submitted. You'll need to add some logic that first deletes rows from the room (P1_ID) that are not in the selection (e.g. P1_ASSIGNED_STUDENTS). You can use APEX_STRING.SPLIT_NUMBERS to help:
delete from map_student_room
where room_id = :P1_ID
and student_id not in (
select column_value
from apex_string.split_number(:P1_ASSIGNED_STUDENTS, ':')
)
Then you can insert rows that are in the selection but not already in the room.
insert into map_student_room (
room_id,
student_id
)
select :P1_ID,
column_value
from apex_string.split_number(:P1_ASSIGNED_STUDENTS, ':')
where column_value not in (
select student_id
from map_student_room
where room_id = :P1_ID
)
I've not tested any of this code, but it should get the points across.
Another option would be to use an Interactive Grid instead of a list of values item. This is a classic master/detail scenario where students could be added and removed below the form region (typically only done after create).
I have a date field and a interactive grid. I am trying to generate the Interactive grid based on the value inputted in the date field.
I am trying to write the query as below :
select pap.effective_start_date , pap.effective_end_date
from per_all_people_f pap
where :SELECT_DATE between pap.effective_start_date and
pap.effective_end_date
Here, SELECT_DATE is the name of the Date field (datatype Date picker). I am writing a dynamic action on Change of Date field, and refreshing the interactive grid region.
But when I change the value in Date field, it doesn't return any rows.
I have done a similar change where my interactive grid was based on a dropdown. There I had to set the "page action on selection" to Submit, and it worked. But here, since it is a Date field, the "Page Action on selection" property doesn't appear on the page .
Can somebody please suggest, how can I achieve this.
You need to explicitly convert your bind variables, which are treated as strings, to dates.
to_date(:SELECT_DATE)
The format mask will come from the application properties, or you can be explicit with that, too.
I'm trying validate two QDateEdits. I have two fields, startdate and enddate and i want to validate that the minimum date of enddate be the selected startdate date. But also, i want give the user opportunity that the enddate field can be empty.
I conected both fields
connect(startDate,SIGNAL(dateChanged(QDate)),endDate,SLOT(setMinDate(QDate)));
startDate and endDate are QDateEdit with a popup calendar.
So, where is the problem here?? When i click over endDate the minimun date it's ok but the next day (fisrt valid date) appears in blue color like it was selected, but when i clicked over that date the popup close and the date it's not set. For example:
When i open the form the startdate field have by default the current date. Latter i click over endDate field and the minimum allowed date is one more day wich it's ok, but this minimum allowed date it's blue marked and when i clicked the date it's not set.
Sorry if my english it's so bad, i hope that you can help me. Thanks any way
I found what my problem is. I connected the slot to dateChanged(QDate) signal, so, by default the QDateEdit set the first allowed date as selected, so if you select it again the signal it's not emited and by result the date it's not set. My solution is use editingFinished() signal instead dateChanged(QDate) signal. I hope has been helpful. Regards,
I am doing a library management system project in QT C++. in handling burrowing of books i use qdatetimeedit to select the current date. I want to assign the return date by adding 2 weeks to the current date and it should be displayed in a line edit once i select the current date from popup calendar. I don't have an idea to carry this out. Please help. Thank you in advance
After trying a lot I figured It up by myself.
QDate current = ui->dtetimeCurrnt->date();
//adding 14 days to the current date to get the returning date
QDate returnDate = current.addDays(14);
//assigning the returndate to dateedit
ui->dteditRetrn->setDate(returnDate);
Since I couldn't use lineEdit I used a dateEdit.