[Qt-interest] Catch QTabPane change event before change
slayer81 at gmx.de
slayer81 at gmx.de
Sun Oct 10 17:02:15 CEST 2010
Hello!
I tried to install an event filter with QObject::installEventFilter(...) which listens to visibility
changes of the QWidget lying on the QTabPane, but when I try to discard the QEvent::Hide,
it has already changed the visibility.
Your suggestion is what I should do. Unfortunately, as soon as I subclass QWidget, I
lose Qt Designer support.
Isnt there a way to prevent pane changes, maybe by fetching the click event on the pane bar
of the QTabPane?
Cheers,
Paule
Am 05.10.2010 10:53:35, schrieb David Boosalis <david.boosalis at gmail.com>:
>
>
> Datum: Tue, 5 Oct 2010 01:53:35 -0700
>
> Betreff:Re: [Qt-interest] Catch QTabPane change event before change
> Von: David Boosalis <david.boosalis at gmail.com>
> An: Matthias Paul <slayer81 at gmx.de>
> Kopie QtInterest <qt-interest at trolltech.com>
> (Cc):
>
>
>
> if you subclass the widgets that go into the tab widget you can capture the
> QWidget::showEvent(QShowEvent *)
> before the tabChange signal gets called. Example follows:
>
>
>
> MyLabel::MyLabel(QString name, QWidget *parent):QLabel(name,parent)
> {
>
> }
>
> void MyLabel::showEvent(QShowEvent *se)
> {
> qDebug() << "Show Me " << QLabel::text();
> QLabel::showEvent(se);
> }
>
> TabChangeExample::TabChangeExample(QWidget *parent)
> : QWidget(parent)
> {
> tabW = new QTabWidget(this);
>
> connect(tabW,SIGNAL(currentChanged(int)),this,SLOT(tabChangedSlot(int)));
> myLabel1 = new MyLabel("ONE",tabW);
> myLabel2 = new MyLabel("Two",tabW);
> tabW->insertTab(0,myLabel1,"Alpha");
> tabW->insertTab(2,myLabel2,"Beta");
> QHBoxLayout *hbox = new QHBoxLayout(this);
> setLayout(hbox);
> hbox->addWidget(tabW);
> }
>
> TabChangeExample::~TabChangeExample()
> {
>
> }
> void TabChangeExample::tabChangedSlot(int i)
> {
> qDebug() << "Tab Changed:" << i;
> }
>
>
>
> When I run this code, the output is as follows:
> Show Me "ONE"
> Tab Changed: 0.
>
> in the showEvent() you could probable do things to change before you show
> it, or in this case before QLabel::showEvent() gets called.
>
>
>
>
>
>
> On Mon, Oct 4, 2010 at 11:37 PM, Matthias Paul <slayer81 at gmx.de> wrote:
> Hello!
>
> I use a QTabPane with three 3 panes. Each panel has some QTextFields for
> user inputs.
> If the user changes input on pane 1 and then tries to switch to pane 2 or
> 3, I'd like to display a message that asks the user whether he wants to
> save his input or not.
>
> There's a signal "currentChange(int)" in QTabPane, which triggers after the
> tab has actually changed. Is there a way to catch a signal _before_ the
> change is going to happen, so I am able to overrule the change?
>
>
> Thank you,
> Paule
> --
> GMX DSL Doppel-Flat ab 19,99 €/mtl.! Jetzt auch mit
> gratis Notebook-Flat! http://portal.gmx.net/de/go/dsl
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list