Results 1 to 2 of 2

Thread: What is the best choice for this firewall settings form

  1. #1
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Question What is the best choice for this firewall settings form

    Hello every one .
    I try to write English carefully. sorry for my English mistakes(probably )
    firewall.jpg
    In the attached photo you can see that I have a treewidget in the left and a stackedwidget in the right. what is the best solution for connecting them together? Is there better widget instead of stackedwidget ?I want for example when somebody clicks "Interface" item from treewidget the right page is selected from stackedwidget
    I have used this code:
    Qt Code:
    1. void FirewallSettings::on_trew_settings_clicked(QModelIndex index)
    2. {
    3. int row;
    4. if( index.parent() == QModelIndex())
    5. row = index.row();
    6. else
    7. row = index.parent().row();
    8.  
    9. int pageNumber = 0;
    10. for( int rowIndex = 0; rowIndex < row; rowIndex++ ){
    11. pageNumber += ui.trew_settings->topLevelItem( rowIndex )->childCount();
    12. pageNumber ++;
    13. }
    14.  
    15. if( index.parent() != QModelIndex()){
    16. pageNumber += index.row();
    17. pageNumber ++;
    18. }
    19.  
    20. ui.sckw_settings->setCurrentIndex( pageNumber );
    21. }
    To copy to clipboard, switch view to plain text mode 
    But I think this is not the best solution for this situation. Help me please .
    thanks
    Impossible = I'mpossible

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What is the best choice for this firewall settings form

    QStackedWidget is a good approach but the code can be much simpler.
    Qt Code:
    1. QTreeWidgetItem* X::addPage(const QString &name, QWidget *configPage, QTreeWidgetItem *parent = 0) {
    2. QTreeWidgetItem *item = parent ? new QTreeWidgetItem(parent) : new QTreeWidgetItem(treeWidget);
    3. item->setText(0, name);
    4. item->setData(0, Qt::UserRole, configPage);
    5. stackedWidget->addWidget(configPage);
    6. return item;
    7. }
    To copy to clipboard, switch view to plain text mode 
    and then:
    Qt Code:
    1. connect(treeWidget, SIGNAL(itemClicked ( QTreeWidgetItem *, int )), this, SLOT(showConfig(QTreeWidgetItem*)));
    2. // ...
    3. void X::showConfig(QTreeWidgetItem *item) {
    4. QWidget *w = item->data(Qt::UserRole).value<QWidget*>();
    5. if(w) stackedWidget->setCurrentWidget(w);
    6. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. is Qt a good choice for S60 SDK 5
    By coco in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 4th May 2010, 21:33
  2. Multiple choice button
    By grisson in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2010, 11:54
  3. Qt language of choice
    By alecs1 in forum Qt Programming
    Replies: 4
    Last Post: 26th April 2009, 21:13
  4. The right choice of IDE
    By LordQt in forum Qt Programming
    Replies: 2
    Last Post: 17th August 2007, 13:21

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.