Home » U++ Library support » U++ Widgets - General questions or Mixed problems » QTF with QtfRichObject as Button label causes crash  
	
		
		
			| Re: QTF with QtfRichObject as Button label causes crash [message #26458 is a reply to message #26438] | 
			Tue, 04 May 2010 17:35   | 
		 
		
			
				
				
				  | 
					
						  
						mirek
						 Messages: 14271 Registered: November 2005 
						
					 | 
					Ultimate Member  | 
					 | 
		 
		 
	 | 
 
	
		It is because QtfRichObject is only temporary reference to the RichObject. 
 
You are using this reference, but then parsing qtf on Button paint, when RichObject does not exist anymore. 
 
One possible solution: 
 
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
GUI_APP_MAIN
{
	Button button;
	
	{
		DrawingDraw dd(63, 187);
		dd.DrawImage(0,0,CtrlImg::exclamation());
	
		static Size ppi(72,72);// = ScreenDraw(true).GetPixelsPerInch();
		QtfRichObject qrdd(CreateDrawingObject(dd.GetResult(), Size(63*ppi.cx/10, 187*ppi.cy/10), Size(63*ppi.cx/10, 187*ppi.cy/10)));
	
		String qtf;
		qtf << qrdd;
		
		button.SetLabel("\1" + AsQTF(ParseQTF(qtf)));
	}
	TopWindow win;
	win.Add(button.SizePos());
	win.Run();
}
 
 
Note: I agree the situation is a little bit tricky, some widgets parse QTF on set (like RichTextView) - this would be no problem for these. Others parse QTF during Paint. Generally, everywhere where QTF needs '\1' prefix, it is being parsed during Paint. 
		
		
		
 |  
	| 
		
	 | 
 
 
 |  
  
 
Goto Forum:
 
 Current Time: Tue Nov 04 03:24:56 CET 2025 
 Total time taken to generate the page: 0.05774 seconds 
 |