Sunday, July 6th 2008, 2:49pm UTC+1

You are not logged in.

  • Login
  • Register

21

Tuesday, May 6th 2008, 11:44am

RE: DataBrowser problem.

Hi messenger,
Thank you for reply.I tried what ever you said,But still i didn't get output in order. I got output like Atttachment 1.
If you dont mind I have one more doubt,that is same as example3. Just little bit change. I attach that .ui form like Attachment 2.


Can you go through and how I stored into Database in this way.

ChannelId , TypeOfSensor , SensorValue
GroupBox1 , Presure , RadioButton
GroupBox2 , Temperature , RadioButton

This is table format. I want the output this way .Can you give me solution for this.Why Because i dont have idea about this. Please ...


Thank you..



Regards,
Tavi.
tavi has attached the following files:
  • Attachment1.bmp (492.81 kB - 5 times downloaded - Last download: May 31st 2008, 2:35pm)
  • Attachment2.bmp (851.62 kB - 5 times downloaded - Last download: Jun 6th 2008, 4:49am)

This post has been edited 1 times, last edit by "tavi" (May 6th 2008, 11:46am)

  • Go to the top of the page

Messenger

Intermediate

Posts: 325

Location: Lt

22

Tuesday, May 6th 2008, 12:28pm

RE: DataBrowser problem.

>>Just little bit change.
Or no. That is a big change.

Well I think the following can be done if you hate to hardcode (and that might be best solution and that is not too hard after all.) all 18 db filling.
To write values to db.
Get all group box. In loop, check if the QGroupBox contains 2 QRadioButton and 2 (or whatever count) QGroupBox (the one draw back that QRadioButton and QGroupBox must be in some way tied (for example have same title and text string or objectName property some parts are the same or deducted from positions :D well everything is possible)). If conditions are met there is QGroupBox, QRadioButton and QRadioButton - write their values to a db.

For sorting use proxy (as I mentioned before). Or there is another sql example.

This one sorts not bad (for test I sort TypeofSensor column. use ChannelID and correct substr values):
"SELECT * FROM Temp ORDER BY CASE WHEN CAST ( substr(TypeofSensor, 13, 5) AS INTEGER) == 0 THEN lower(TypeofSensor) ELSE CAST ( substr(TypeofSensor, 13, 5) AS INTEGER) END"

Example project (with _final_ widgets positions and hierarchy) would be good to look farther.
And please - attach png files.
Fighting fire with fire.
  • Go to the top of the page

23

Thursday, May 15th 2008, 11:23am

RE: DataBrowser problem.

Hi Messenger,
What ever you said.That i followed and tried to hardcode the application.still Baffeled.I think ter are some mistakes in my code
I attached code what ever i did in application.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
void spare_channel::on_pushButton_clicked()
{
	QList<QRadioButton*> rbtns = this->findChildren<QRadioButton*>();
    int i,j;
    for (i = 0; i < rbtns.count(); ++i)
    {
        // lookup group box
        QGroupBox *gb = qobject_cast<QGroupBox*>(rbtns.at(i)->parent());
        if (gb && rbtns.at(i)->isChecked())
        {
			for(j=0;j<rbtns.count();++j)
			{
				QGroupBox *gb=qobject_cast<QGroupBox*>(rbtns.at(i)->parent());
				if(gb&&rbtns.at(i)->isChecked())
				{
					QString qu("INSERT or REPLACE INTO Spar VALUES('%1', '%2','%3')");
					qu = qu.arg(gb->title())
						.arg(rbtns.at(i)->text())
						.arg(rbtns.at(j)->text());
					QSqlQuery q;
					if (!q.exec(qu))
					{
						QMessageBox::information(this, "Failed SQL query", q.lastError().text() + "\n" + q.lastQuery());
					}
				}
			}	
		}
	}
}



This is the code functionality for when i click the PushButton ,I want to save the data in table .That table should be Corresponding GUI data saved in to database.


s.no / ChannelName / Type of sensor / Sensorvalue

1 / sparechannel / temperature / prt-100ohm


Please helpme Messenger,


Thankyou..



Regards,
Tavi.

This post has been edited 2 times, last edit by "tavi" (May 15th 2008, 2:34pm)

  • Go to the top of the page

Messenger

Intermediate

Posts: 325

Location: Lt

24

Friday, May 16th 2008, 8:40am

RE: DataBrowser problem.

Hi,
by hardcoding I have suggested to do all work by hand. Like

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if (m_RadioButton1.isChecked()) // of course instead of m_RadioButton1 there must be meaningful name of the radio button.
{
   if (m_RadioButton2.isChecked())
   {
      if (m_RadioButton3.isChecked())
       {
           ...save to a database some values...
       }
      if (m_rbPressure10Atm.isChecked())
      {
           ...save to db...
      }
       ....
   }
    .....
}
...

I have attached little example (the examining of objects hierarchy and...). Looks like works like is expected.
Messenger has attached the following file:
  • example4.zip (7.88 kB - 3 times downloaded - Last download: May 31st 2008, 3:24pm)
Fighting fire with fire.
  • Go to the top of the page

25

Monday, May 26th 2008, 7:54am

Hi messenger ,
Thanks for your reply.Your example 4 is working,But i just change your ui design. I attached that ui file. I want same output.and one more problem when i select the Temperature Button Particular groupbox will Enable and Another one will be Disabled.
please solve this problem.


Advance Thanks,
Regards.
Tavi.
tavi has attached the following file:
  • tavi1.zip (19.18 kB - 3 times downloaded - Last download: May 31st 2008, 2:02pm)
  • Go to the top of the page

Messenger

Intermediate

Posts: 325

Location: Lt

26

Monday, May 26th 2008, 8:54am

There is little example based on the 4th example.
Looks like works as expected.
Messenger has attached the following file:
  • example5.zip (6.21 kB - 4 times downloaded - Last download: May 31st 2008, 2:04pm)
Fighting fire with fire.
  • Go to the top of the page

27

Monday, May 26th 2008, 11:51am

Hi messenger,
Thank you for ur reply, your Example 5 is working . But I changed my ui design ,that is Small ,Instead of title names of Group Box(Temperature& pressure) i put Select as the title name for both the groupBoxes.I wanted to save the RadioButton Text which i have selected. I wanted to save which RadioButton i have selected either Temperature or Pressure in the Type of Sensor field of the db. And the selected Radio Buttons from the select Group (5K or 10C or 100 C or 500C)to the value field of the db.

Quoted

Pls check the previous attachment.
Thanks,
Regards
  • Go to the top of the page

Messenger

Intermediate

Posts: 325

Location: Lt

28

Monday, May 26th 2008, 2:42pm

The change was Big one. Yet another example. In which inner group boxes does not have title at all (that is choice not depends on QGroupBox title, but depends on the x positions). Looks like works.
Messenger has attached the following file:
  • exampleX.zip (6.2 kB - 3 times downloaded - Last download: May 31st 2008, 2:34pm)
Fighting fire with fire.
  • Go to the top of the page

29

Saturday, May 31st 2008, 8:22am

Hi messenger,
Thank you for help till now.I got the solution.Now I have small doubts , Will Sqlite Supports large data base ?...Since Qt doest support USB communication i have got a USB Win 32 lib from net.http://libusb-win32.sourceforge.net/. I am still figuring out how to use it with Qt program, can you pls guide me on how to use it.


Thanks..........



Regards,
Tavi.

This post has been edited 2 times, last edit by "tavi" (May 31st 2008, 1:03pm)

  • Go to the top of the page

Rate this thread