So I have to make my own class? Or reimplement the QLabel class and add event handlers?
So I have to make my own class? Or reimplement the QLabel class and add event handlers?
Well... I know this sounds nooby, but how would I use the installEventFilter()? I read the Key-press-eater, but how does that work? Do I have to make a seperate eventFilter class? And attach that to an object usign coding - not designer? THanks in advance - codeslicer
You can use any existing QObject subclass as an event filter. It could be for example your window class which loads the designed ui.
J-P Nurmi
Ok... how would the code work for it though? And is there any way that I can integrate it into Qt Designer, or do I have to somehow place it in there using code only![]()
Qt Designer is a layout designer. You don't implement functionality in Qt Designer. You implement functionality by writing code.
J-P Nurmi
Ok... but how would I do that though? I know how to arrange the form, I'll figure it out by looking at the generate header-from-uic file, but how can I make that event filter and how would I use it with a QLabel (or a subclassed QLabel)![]()
So how do you use that form you created in Qt Designer? Are you using single or multiple inheritance approach?
J-P Nurmi
I had a similar scenario with a row of PushButtons that I wanted to change color as the mouse was over them. They were implemented flat in QTDesigner with mouseTracking set true. Text in a QLabel also changed depending on the PushButton under the cursor.
Qt Code:
{ int X = event->x(); int Y = event->y(); if( X > 0 && X < 160) { if( Y > 0 && Y < 80) { textLabel->setText( twString); } else etc.To copy to clipboard, switch view to plain text mode
I'm sure you could accomplish the same thing with a group of QLabels merged together so they would look like a single object until changed by the cursor.
codeslicer (17th February 2008)
Finally, someone who answers not to just get their post count up. Brilliant idea, thanks a lot
![]()
Sorry jpn, didn't see your comment
I'm using multiple-inheritance, so do I have to have several QLabels in the same place, each being transparent in all places except for where the button would be? If so, how would I switch their order from top to bottom?
Oh, and in the code above, what would I replace Clone with, a subclass of a QLabel, or the name of my label that I want to switch?
Thanks in advance ~codeslicer
*bump* Anyone?
Clone is the base widget that I populate with 4 QPushButtons, 2 QRadioButtons and 2 QLabels. The RadioButtons are invisible and superimposed on one of the pushbuttons. They are set visible after the button is clicked and set invisible again after one or the other is clicked launching a QProcess.
Intent is to emulate an html page.
Bookmarks