Results 1 to 4 of 4

Thread: QTabWidget issue

  1. #1
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt5
    Platforms
    Unix/X11

    Unhappy QTabWidget issue

    Hi There,

    I got a little UI going with a QTabWidget on it. On the bottom I have
    two buttons, "<< perevious" and "next>>" with which i wanna let the
    user "scroll" through the tabs. I'm using following method to switch the tab but if i press the button, nothing happens:
    Qt Code:
    1. connect(widget.NextBtn, SIGNAL(clicked()), this, SLOT(NextTab(int current)));
    2. ...
    3. ...
    4. void HelloForm::NextTab(void){
    5. if (widget.tabWidget->currentIndex()!=-1)
    6. {
    7. widget.tabWidget->setCurrentIndex(this->TabIndex=+1);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    What am I doing wrongly?

    Thank you for help!
    roN

  2. #2
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTabWidget issue

    Hi,
    the slot statement in the connect isnt right ,there is no variable name in the paranthesis in connect it should be like ...SLOT(NextTab(int)) ....and for the same function you are using int in the paranthesis while in the function itself it is void..

  3. #3
    Join Date
    Jun 2010
    Posts
    7
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QTabWidget issue

    Quote Originally Posted by salmanmanekia View Post
    Hi,
    the slot statement in the connect isnt right ,there is no variable name in the paranthesis in connect it should be like ...SLOT(NextTab(int)) ....and for the same function you are using int in the paranthesis while in the function itself it is void..
    Great, thank you, I changed this to
    current code:
    Qt Code:
    1. connect(widget.NextBtn, SIGNAL(clicked()), this, SLOT(NextTab()));
    2. ..
    3. ..
    4. void HelloForm::NextTab(void){
    5. if (widget.tabWidget->currentIndex()!=-1)
    6. {
    7. widget.tabWidget->setCurrentIndex(this->TabIndex=+1);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    And got it partially working. I get it to go to tab2 but for some reason it doesn't go to the third one...
    And also my perevious button isn't working at all:
    Qt Code:
    1. connect(widget.PereviousBtn, SIGNAL(clicked()), this, SLOT(PereviousTab()));
    2. ...
    3. ...
    4. void HelloForm::PereviousTab(void){
    5. if (widget.tabWidget->currentIndex()!=-1)
    6. {
    7. widget.tabWidget->setCurrentIndex(this->TabIndex=-1);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    Any more clues?

    Thanks,
    roN

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTabWidget issue

    Why are you setting the index on widget.tabWidget, but getting the index from this->TabIndex?

    Try splitting things up into two calls: the first to obtain the current index, the second to set it. Then print out the values at each step to confirm that A) your slots are getting called as you expect, and B) the correct values are being obtained and computed.

Similar Threads

  1. QTabWidget
    By Freeman551 in forum Qt Programming
    Replies: 3
    Last Post: 25th December 2009, 00:06
  2. QTabWidget
    By conatic in forum Qt Programming
    Replies: 1
    Last Post: 16th September 2008, 20:05
  3. How do I add new tab to QTabWidget
    By pcmantinker in forum Qt Programming
    Replies: 2
    Last Post: 6th June 2008, 04:24
  4. QTabWidget
    By allstar in forum Qt Programming
    Replies: 1
    Last Post: 5th December 2007, 19:18
  5. QTabWidget tab
    By baray98 in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2007, 00:16

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.