Results 1 to 6 of 6

Thread: QTabWidget problem

  1. #1
    Join Date
    Jul 2008
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTabWidget problem

    Hi,

    I'm having a problem with QTabWidget
    O/s is Windows, Development environment VS2005, QT version 4.3.4

    I have a QTabWidget called MainNotebook and I'm trying to connect its currentChanged(int index) signal to my private slot void on_PageChange(int new_page);

    This is the connect macro:
    connect(ui.MainNotebook,SIGNAL(currentChanged()),t his,SLOT(on_PageChange()));

    This is the signature of my slot:
    void on_PageChange(int new_page);

    The problem is simple - my slot doesn't seem to ever be called (I put a break point on it to check this was the case). On the other hand, all the other signal/slot connections work OK.

    I'm sure I'm making a really simple mistake here, but I just can't see what!

    Can anyone help, please?

    alan

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTabWidget problem

    Does the class declaration contain the required Q_OBJECT macro? Is on_PageChange() declared as slot? QObject::connect() outputs a warning in case establishing the signal slot connection fails, see debug output for more details.
    J-P Nurmi

  3. #3
    Join Date
    Jul 2008
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget problem

    Does the class declaration contain the required Q_OBJECT macro?
    Yes

    Is on_PageChange() declared as slot?
    Yes - it's declared as a private slot

    QObject::connect() outputs a warning in case establishing the signal slot connection fails, see debug output for more details.
    OK - I just found this amongst all the crud that VS2005 outputs when it's running!

    QMetaObject::connectSlotsByName: No matching signal for on_PageChange(int)

    and then a bit later:

    Object::connect: No such signal QTabWidget::currentChanged()
    Object::connect: (sender name: 'MainNotebook')
    Object::connect: (receiver name: 'EvEditClass')

    I'm still no sure what I'm doing wrong, though - this is the Qt Assistant entry for the signal:

    void QTabWidget::currentChanged ( int index ) [signal]
    This signal is emitted whenever the current page index changes. The parameter is the new current page index position.


    Thanks for your help, anything further would be appreciated, since I still can't see the problem...

    alan

    _

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTabWidget problem

    Quote Originally Posted by alan lenton View Post
    Object::connect: No such signal QTabWidget::currentChanged()
    Object::connect: (sender name: 'MainNotebook')
    Object::connect: (receiver name: 'EvEditClass')
    Ahh, indeed. It should be:
    Qt Code:
    1. connect(ui.MainNotebook,SIGNAL(currentChanged(int)),this,SLOT(on_PageChange(int)));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. #5
    Join Date
    Jul 2008
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget problem

    thank you!

    alan

  6. #6
    Join Date
    Jul 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QTabWidget problem

    Thank you very much!!

Similar Threads

  1. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  2. StyleSheet Problem with QTabWidget
    By December in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 22:16
  3. QTabWidget Parenting Problem
    By mclark in forum Newbie
    Replies: 4
    Last Post: 18th January 2007, 15:20
  4. QTabWidget - problem with resizing
    By moowy in forum Qt Programming
    Replies: 5
    Last Post: 14th September 2006, 14:06
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.