Transparent TextEdit or Widget
Hi, all
I need a transparent widget which could insert some text string on another widget. In fact, just like Photo-Shop, there is a image as background and user can edit text on the image.
Does anybody can tell me how I can do it or give some good advices for me! Thanks!
Re: Transparent TextEdit or Widget
do you mean that the user can select anywhere on the image they want and the text must go there? or is there some fixed place where the text will go and they will just be able to see the image through as the background?
Re: Transparent TextEdit or Widget
Set a totally transparent color for text edit's background.
From QPalette docs:
Quote:
QPalette::Base - Used as the background color for text entry widgets; usually white or another light color.
Code:
textEdit->setPalette(p);
Re: Transparent TextEdit or Widget
Quote:
Originally Posted by georgie
do you mean that the user can select anywhere on the image they want and the text must go there? or is there some fixed place where the text will go and they will just be able to see the image through as the background?
As you think, what I want to do is that user can select anywhere on the image they want and instert the text there. Can you give some advices? Thanks a lot!
Re: Transparent TextEdit or Widget
Quote:
Originally Posted by jpn
Set a totally transparent color for text edit's background.
From
QPalette docs:
Code:
textEdit->setPalette(p);
Thank you for your code, I'll try it right now!
Re: Transparent TextEdit or Widget
i suspect you would have to subclass QImage and reimplement the mouseClickEvent to initialize a new textEdit where the click was made
Re: Transparent TextEdit or Widget
almost-code might be
Code:
Q_OBJECT
public:
MyImage(...);
protected:
private:
};
MyImage(..)
{
something;
}
{
//do whatever you do to make it see through
te->move(event->pos());
//i haven't played around but I think you should be able to see the cursor
//and be able to type now
}
Of course I don't know how you want to go about it exactly (1 text edit at a time/more?? editable in the future??) but those things should be easy enough to work out once you get the first one happening I figure :)
Re: Transparent TextEdit or Widget
Code:
Q_OBJECT
public:
MyImage(...);
protected:
private:
};
MyImage(..)
{
something;
}
{
//do whatever you do to make it see through
te->move(event->pos());
//i haven't played around but I think you should be able to see the cursor
//and be able to type now
}
In the above code, every time mouse is pressed a new text edit is created. Where is old text edit ? Where are you deleting it ?
Re: Transparent TextEdit or Widget
yer of course, that's why I said that would depend upon what exactly they wanted to do with it...I didn't bother doing more code because the initial qn was not too specific....
once you get one that appears as you want it too, it'd be pretty easy to get new ones and keep track of them....and if it was really like the photoshop way of doing things, where you have to click a button to be able to get the text edit cursor and then when you click a new text edit appears there would have to be some sort of signal from the button setting a flag which turns the new text edit creation on/off....and it would have to deal with the fact that if you clicked again within an already existing text edit you do not want to create a new one but edit the existing one.....
but like i said, none of these parameters were mentioned in the qn so it's hard to know how to deal with any of that stuff ;)