Results 1 to 3 of 3

Thread: QTabWidget setCurrentIndex() problems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2012
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question QTabWidget setCurrentIndex() problems

    I've been having a mysterious problem with my QTabWidget.

    This is not working.
    Qt Code:
    1. ui->TabWidget->setCurrentIndex(settings.value("tab_index", 1));
    To copy to clipboard, switch view to plain text mode 

    It throws this error:
    Qt Code:
    1. error: no matching function for call to 'QTabWidget::setCurrentIndex(QVariant)
    To copy to clipboard, switch view to plain text mode 

    However, this code works:
    Qt Code:
    1. settings.setValue("tab_index", ui->TabWidget->currentIndex());
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTabWidget setCurrentIndex() problems

    Ehm, int != QVariant. value() is returning a QVariant, so you have to call toInt() on it.

  3. #3
    Join Date
    Mar 2012
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTabWidget setCurrentIndex() problems

    Quote Originally Posted by Lykurg View Post
    Ehm, int != QVariant. value() is returning a QVariant, so you have to call toInt() on it.
    Thank you! I'm a bit new to qt4, and C++ in general.

Similar Threads

  1. QListView - setCurrentIndex()
    By Tomasz in forum Newbie
    Replies: 1
    Last Post: 29th December 2010, 11:48
  2. Replies: 1
    Last Post: 10th December 2009, 21:31
  3. QTabBar/QTabWidget problems on S60
    By ojai0217 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 25th October 2009, 01:30
  4. QTabWidget clicking problems after addTab()
    By DonSam in forum Qt Programming
    Replies: 0
    Last Post: 14th October 2008, 08:28
  5. Problems with CSS for QTabBar and QTabWidget
    By visor_ua in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2008, 08:38

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
  •  
Qt is a trademark of The Qt Company.