Friday, 26 August 2011

Dynamically removing QWidgets from a QLayout

I’ve seen some strange things when trying to remove QWidgets from a QLayout while using code such as:

MyWidget->layout()->removeWidget(AnotherWidget);

Sometimes AnotherWidget wouldn’t be removed, sometimes it would display only part of it.

After a bit of searching I came across a different solution that worked a treat. The below code removes all widgets MyWidget’s layout.


while((QLayoutItem *child = MyWidget->layout()->takeAt(0)) != 0)
{
delete child->widget();
delete child;
}

And if you wanted to only remove a single widget from the layout:

while((QLayoutItem *child = MyWidget->layout()->takeAt(0)) != 0)
{
if(child == AnotherWidget)
{
delete child->widget();
delete child;
}
}

Friday, 11 March 2011

Using 3CXPhone with Sipgate

Sipgate’s own software phone doesn’t work on Windows 7 so I had to find an alternative and chose 3CXPhone.

It’s taken a little time to get it to connect to my Sipgate account so here is the configuration I used to get it to work:

3CXPhone Configuration for Sipgate


Account name and Caller ID can be anything you like.

Change “Extension” and “ID” to your Sipgate ID.

You also need to set the STUN server by clicking on “Advanced Settings” from the Configuration window:

3CXPhone Advanced Settings for Sipgate