EricF
25th October 2007, 20:26
Hi,
I'm trying to familiarize myself with the splitter object and coded a little program to experiment with it. I have an object that triggers the split. Here's the header
class WidgetSplitter
{
Q_OBJECT
public:
WidgetSplitter( QWidget* parent = 0 );
signals:
void SplitVertical();
void SplitHorizontal();
void Unsplit();
protected slots:
void SplitVerticalButtonClicked();
void SplitHorizontalButtonClicked();
void UnsplitButtonClicked();
};
I then derived QSplitter(MySplitter) to listen for signals WidgetSplitter is sending. The first time MySplitter receives a split signal, it sets the orientation and add another instance of WidgetSplitter. When orientation is set, as long as user click the split with the same orientation, MySplitter adds another instance of WidgetSplitter. When user wants to split in the other direction, MySplitter replaces the current WidgetSplitter instance by another MySplitter and add twos instances of WidgetSplitter. Unfortunately, when this occurs, it crashes.
The only way I know to remove a widget from a QSplitter is by deleting it. I tried reparenting but with no success. To replace it, I first use indexOf to find position and the delete it. I create a new MySplitter, adds the two WidgetSplitter and insert it at the found index. Obviously this triggers a LayoutRequest and when splitter handles it, the previously deleted widget is still part of the layout and it crashes. I tried deleteLater because I thought it was safer but it's still crashing. Why QSplitter doesn't handle it correctly ?
I'm trying to familiarize myself with the splitter object and coded a little program to experiment with it. I have an object that triggers the split. Here's the header
class WidgetSplitter
{
Q_OBJECT
public:
WidgetSplitter( QWidget* parent = 0 );
signals:
void SplitVertical();
void SplitHorizontal();
void Unsplit();
protected slots:
void SplitVerticalButtonClicked();
void SplitHorizontalButtonClicked();
void UnsplitButtonClicked();
};
I then derived QSplitter(MySplitter) to listen for signals WidgetSplitter is sending. The first time MySplitter receives a split signal, it sets the orientation and add another instance of WidgetSplitter. When orientation is set, as long as user click the split with the same orientation, MySplitter adds another instance of WidgetSplitter. When user wants to split in the other direction, MySplitter replaces the current WidgetSplitter instance by another MySplitter and add twos instances of WidgetSplitter. Unfortunately, when this occurs, it crashes.
The only way I know to remove a widget from a QSplitter is by deleting it. I tried reparenting but with no success. To replace it, I first use indexOf to find position and the delete it. I create a new MySplitter, adds the two WidgetSplitter and insert it at the found index. Obviously this triggers a LayoutRequest and when splitter handles it, the previously deleted widget is still part of the layout and it crashes. I tried deleteLater because I thought it was safer but it's still crashing. Why QSplitter doesn't handle it correctly ?