Qt-interest Archive, March 2002
Request : QFileDialog::setContentsPreview() side-effect
Message 1 in thread
Hello Trolls,
I noticied that when one uses QFileDialog::setContentsPreview(), the
previous preview object is deleted (the pointer is freeed), not just
replaced.
Isn't this a strange side-effect ? Why delete the pointer on a previewer
given before ? I would be nice if this behaviour was at least notified in
the documentation, in my humble opinion.
I have here to manipulate many file types, but different types may share
the same filters. When the user change the file type, I need to change the
preview widget, thus calling QFileDialog::setContentsPreview(). It would
be much easier for me if the previously installed one was not deleted,
so I can reuse it later if needed !
What about changing this function prototype to something like :
void setContentsPreview(QWidget *w, QFilePreview *preview, bool del = true)
...and then, delete the previously installed preview only if del is true...
The default value ensure that it would not interfere with existing code.
Side note : I guess the trouble is more or less the same with informations.
Best regards,
--
[ signature omitted ]
Message 2 in thread
Hi,
You can for example use QWidgetStack, which will be inserted with
QFileDialog::setContentsPreview(), and depending on file type just raise
appropriate widget with QWidgetStack::raiseWidget()...
Greetz
JK
Yves Bailly wrote:
> Hello Trolls,
>
> I noticied that when one uses QFileDialog::setContentsPreview(), the
> previous preview object is deleted (the pointer is freeed), not just
> replaced.
>
> Isn't this a strange side-effect ? Why delete the pointer on a previewer
> given before ? I would be nice if this behaviour was at least notified in
> the documentation, in my humble opinion.
>
> I have here to manipulate many file types, but different types may share
> the same filters. When the user change the file type, I need to change the
> preview widget, thus calling QFileDialog::setContentsPreview(). It would
> be much easier for me if the previously installed one was not deleted,
> so I can reuse it later if needed !
> What about changing this function prototype to something like :
> void setContentsPreview(QWidget *w, QFilePreview *preview, bool del = true)
> ...and then, delete the previously installed preview only if del is true...
> The default value ensure that it would not interfere with existing code.
>
> Side note : I guess the trouble is more or less the same with informations.
>
> Best regards,
>
> --
> /- Yves Bailly - Software developper -\
> \- Sescoi France http://www.sescoi.fr -/
> "C makes it easy to shoot yourself in the foot. C++ makes it harder,
> but when you do, it blows away your whole leg." - Bjarne Stroustrup
>
> --
> List archive and information: http://qt-interest.trolltech.com
Message 3 in thread
Hello,
Jarek Kobus wrote:
> You can for example use QWidgetStack, which will be inserted with
> QFileDialog::setContentsPreview(), and depending on file type just raise
> appropriate widget with QWidgetStack::raiseWidget()...
>
> Yves Bailly wrote:
>>
>>I noticied that when one uses QFileDialog::setContentsPreview(), the
>>previous preview object is deleted (the pointer is freeed), not just
>>replaced.
Thanks a lot for this idea, it's definitely the thing to do (at least in
my case).
But it still think the option I suggest would be nice, and that the fact
the preview widget is deleted should be mentioned in the doc.
Regards,
--
[ signature omitted ]