Results 1 to 6 of 6

Thread: How to access Widgets created in Tab View

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    66
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default How to access Widgets created in Tab View

    Hi,
    I am new to Qt Environment, i am using a QTabWidget where i am adding eight tabs to it in a for loop. the elements present on each page of the tab are same.

    I am not able to get the control of widgets present on the 1st tab, can someone please help me on how can i get the control back on the tab one.
    Pasting the code snippet.

    Qt Code:
    1. tabWidget = new QTabWidget(parent);
    2. tabWidget->setGeometry(0,15,650,400);
    3. tabWidget->setStyleSheet("*{background-color:green;}");
    4.  
    5. for(int i=0; i<8;i++){
    6.  
    7. QString name(QString::number(1));
    8. tabWidget->addTab(myfunction(),tr("Profile").append(name));
    9. }
    10. connect(Modelcombo,SIGNAL(currentIndexChanged(int)),this,SLOT(stCurrentIndex(int)));
    11. connect(colorModecombo,SIGNAL(currentIndexChanged(int)),this,SLOT(stCurrentIndex(int)));
    12. }
    13.  
    14. /*The function is */
    15. QWidget* Widget::myfunction(){
    16.  
    17. page = new QWidget();
    18. page->setGeometry(0,25,650,500);
    19.  
    20. QLabel *Modelab = new QLabel(tr("Modle"),page);
    21. Modelab->setGeometry(0,60,120,20);
    22. Modelcombo = new QComboBox(page);
    23. ModelcombosetGeometry(200,60,100,20);
    24. Modelcombo->setFocusPolicy(Qt::NoFocus);
    25. Modelcombo->addItem(tr("Normal"));
    26. Modelcombo->addItem(tr("Bad"));
    27. Modelcombo->addItem(tr("Good"));
    28.  
    29. QLabel *colorModelab = new QLabel(tr("Color"),page);
    30. colorModelab->setGeometry(0,100,80,20);
    31. colorModecombo = new QComboBox(page);
    32. colorModecombo->setGeometry(200,100,100,20);
    33. colorModecombo->setFocusPolicy(Qt::NoFocus);
    34. colorModecombo->addItem(tr("Red"));
    35. colorModecombo->addItem(tr("Blue"));
    36. colorModecombo->addItem(tr("Green"));
    37.  
    38. return page;
    39. }
    40. /*the Slot is*/
    41. void Widget::stCurrentIndex(int val){
    42. qDebug()<< "Tab value is" << tabWidget->currentIndex();
    43. qDebug()<< "Modle mode is" << Modelcombo->currentText();
    44. qDebug()<< "Color is" << colorModecombo->currentText();
    45. }
    To copy to clipboard, switch view to plain text mode 

    As the content in each tab is the same when i try to connect to signal of combobox in tab 1, the signal is not emitted, but the signal is emitted for the last tab created. Please let me know hw to proceed from here as i want to extract the values of combobox of wach tab.
    Last edited by wysota; 23rd October 2009 at 00:32. Reason: missing [code] tags

Similar Threads

  1. how to access widgets values?
    By BalaQT in forum Qt Programming
    Replies: 4
    Last Post: 22nd August 2009, 12:06
  2. Replies: 6
    Last Post: 3rd September 2008, 14:27
  3. Access to widgets from a Dialog to another one
    By jean in forum Qt Programming
    Replies: 7
    Last Post: 7th August 2008, 09:42
  4. raised view of Widgets.
    By krishna.bv in forum Qt Programming
    Replies: 22
    Last Post: 25th January 2007, 11:21
  5. Access widgets
    By Gayathri in forum Newbie
    Replies: 2
    Last Post: 17th November 2006, 14:37

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.