I am using a QProcess to scan the available bluetooth devices. The QProcess uses command line commands like hcitool scan to check for available devices. The output is parsed using regular expressions and I have cells(equal to number of devices scanned) of datastructure with details like device name, channel for OPUSH, type of device, device address.
To display all the devices I use QListWidget
//Display on list widget
//Send all information regarding device name, address, OPUSH channel and icon
//to child widget myBTwidget
myBTwidget *MyItem = new myBTwidget();
MyItem->BTName(DeviceName);
MyItem->BTAddress(address);
MyItem->BTChannelNo(channel);
MyItem->BTIcon(icon);
QListWidgetItem *item=new QListWidgetItem();
item->setSizeHint(QSize(720,50));
this->ui->listWidget->addItem(item);
//Add child widget myBTwidget to list widget
this->ui->listWidget->setItemWidget(item,MyItem);
The custom child widget has 1. a label showing the image for the type of device 2. a button (flat) displaying the device name 3. a label stating if OPUSH channel to send files is available or not
The listwidgetitem pushbutton is clicked, it pairs the with the bluetooth device and sends files. I would like to connect QListwidgetitem clicked() signal to the childwidget pushbutton containing the device name clicked() slot. In this way the user can press anywhere on the item and the device pairs and sends file.
How do i go about it?
The listwidget is in the parent class,and the item is a child widget. I tried connecting the clicked signal of qlistwidgetitem to a slot onitemclicked(). In onitemclicked() function I tried calling the function within custom childwidget that implements the pushbutton clicked function, but since it wouldnt have details like device name, Address, channel it cannot do the operation.
If I were to simply click on the child widget pushbutton containing the text as device name, it has all the details and will do the pairing and send operation.
I thought of few solutions, 1.create a global structure and save the data in it and utilize OR 2. create a table in database and save the data while parsing loading child widgets and use this data to call the function to send the file
I would like to know is there a better way to go about it? If I can have individual listwidgetitem details sent to custom child widget stored in someway and on clicking the item, get all the details and call the function to do the pairing and send file??
Kindly please help me out.
Thank you