|
| ServiceModel (ServiceBrowser *browser, QObject *parent=nullptr) |
| Creates a model for the given service browser and starts browsing for services.
|
|
int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
|
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
|
virtual bool | hasIndex (int row, int column, const QModelIndex &parent) const |
|
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
|
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
|
QModelIndex | parent (const QModelIndex &index) const override |
|
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
|
Model for list of Zeroconf services.
This class provides a Qt Model for ServiceBrowser to allow easy integration of service discovery into a GUI. For example, to show the HTTP servers published on the local network, you can do:
);
QComboBox *serviceCombo = new QComboBox();
serviceCombo->setModel(serviceModel);
Browses for network services advertised over DNS-SD.
Definition servicebrowser.h:55
Model for list of Zeroconf services.
Definition servicemodel.h:54
After the user makes a selection, the application typically needs to get a pointer to the selected service in order to get the host name and port. A RemoteService::Ptr can be obtained from a QModelIndex using:
void onSelected(const QModelIndex &selection) {
KDNSSD::RemoteService::Ptr service =
.value<KDNSSD::RemoteService::Ptr>();
}
@ ServicePtrRole
gets a RemoteService::Ptr for the service
Definition servicemodel.h:60
- Since
- 4.1
- Author
- Jakub Stachowski