Results 1 to 8 of 8

Thread: KDialog, tabs, get active tab pushbuttons, qradiobuttons

  1. #1
    Join Date
    Apr 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Thumbs down KDialog, tabs, get active tab pushbuttons, qradiobuttons

    Hei!

    Small ui file -> contains QTabWidget
    And cpp file I'm adding radiobuttons.
    How to get active radiobuttons and something?

    Qt Code:
    1. newTab is QWidget (QRadioButtons etc)
    2.  
    3. MyClass::MyClass( const QString &handle, const QString &name )
    4. : KDialog()
    5. , Ui::MyWindow()
    6. {
    7. .....
    8. QRadioButtons
    9. .....
    10. newTab->setLayout( layout );
    11. tabWidget->addTab( newTab, name );
    12. .....
    13. }
    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: KDialog, tabs, get active tab pushbuttons, qradiobuttons

    Loop through your radio buttons and check if they are selected. And you might want give KDialog a parent.

  3. #3
    Join Date
    Apr 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: KDialog, tabs, get active tab pushbuttons, qradiobuttons

    Ok, how to get active tab's qradiobuttons? I call this class many times (and everytime opens new tab, wich contains radiobuttons etc).

  4. #4
    Join Date
    Apr 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: KDialog, tabs, get active tab pushbuttons, qradiobuttons

    How to loop QRadioButtons?

  5. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: KDialog, tabs, get active tab pushbuttons, qradiobuttons

    All your objects have names, use those to check each and every radio button.

    myRadioButton->isChecked();
    myRadioButton->setChecked(true or false);

    Change myRadioButton with the name of another radio button etc...

    Now, if you want to make it yourself a lot easier, create a list of radiobuttons.
    Qt Code:
    1. QList<QRadioButton *> myRadioButtons;
    2.  
    3. QRadioButton *newRadioButton = new QRadioButton(this);
    4. myRadioButtons.append(newRadioButton);
    5. etc...
    6.  
    7. foreach(QRadioButton *button, myRadioButtons) {
    8. if (button->isChecked()) {
    9. // do something
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

  6. The following user says thank you to tbscope for this useful post:

    sang (27th August 2010)

  7. #6
    Join Date
    Apr 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: KDialog, tabs, get active tab pushbuttons, qradiobuttons

    Qt Code:
    1. QList<QRadioButton *> aRadioButtons;
    2. aOption_ = new QRadioButton( "&a Option:", this );
    3. gList_ = new QListWidget( this );
    4. alOption_ = new QRadioButton( "&b option", this );
    5. bOption_ = new QRadioButton( "&c option", this );
    6.  
    7. aRadioButtons.append( aOption_ );
    8. aRadioButtons.append( alOption_ );
    9. aRadioButtons.append( bOption_ );
    To copy to clipboard, switch view to plain text mode 

    either way I can, too?

  8. #7
    Join Date
    Apr 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: KDialog, tabs, get active tab pushbuttons, qradiobuttons

    I'm tring that:
    Qt Code:
    1. QList<QRadioButton *> myList;
    2. int index = 0;
    3. if( myLits.at(index)->isChecked() )
    4. {}
    To copy to clipboard, switch view to plain text mode 

  9. #8
    Join Date
    Apr 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: KDialog, tabs, get active tab pushbuttons, qradiobuttons

    I have a problem, I have a window but I would like to be a new tab.

    Qt Code:
    1. Dialog *dialog = new Dialog( param );
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. Dialog::Dialog( const QString& param, QWidget* parent )
    2. : QWidget( parent )
    3. , Ui::Dialog()
    4. {
    5. setupUi( this );
    6.  
    7. // Set up the label
    8. ...... etc
    9.  
    10.  
    11. layout->addWidget( ... etc );
    12.  
    13. TabWidget->setLayout( layout );
    14.  
    15. tabWidget->addTab( TabWidget, "new tab" );
    16. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Using ICONs as PushButtons
    By sudhakaran in forum Newbie
    Replies: 10
    Last Post: 4th February 2010, 18:34
  2. Three pushButtons in a shape of one
    By Kenji_Takahashi in forum Qt Programming
    Replies: 13
    Last Post: 7th September 2009, 19:25
  3. Pushbuttons with fixed aspect ratios?
    By WinchellChung in forum Newbie
    Replies: 3
    Last Post: 19th December 2007, 18:38
  4. kdialog and klocate problems
    By parsito in forum Newbie
    Replies: 46
    Last Post: 22nd May 2007, 09:29
  5. Problems connecting PushButtons
    By Randulf in forum Newbie
    Replies: 3
    Last Post: 23rd August 2006, 14:39

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.