Results 1 to 6 of 6

Thread: Acces a stacked widget...?

  1. #1
    ucomesdag Guest

    Question Acces a stacked widget...?

    I 'm was looking at the Config Dialog example (http://doc.trolltech.com/4.2/dialogs-configdialog.html)
    and was wondering how to get the data to use in the main function.

    I want to use something similar but don't see how to acces the data.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Acces a stacked widget...?

    This is a made up example, so you can't access data easily, but in normal situation all *Page widgets would keep pointers to their children, so that you can read the settings. You can also add read() and write() methods that would read/store those settings in application's configuration.

  3. #3
    ucomesdag Guest

    Default Re: Acces a stacked widget...?

    Is there someway to do it like this dialog->pagesWidget->currentWidget()?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Acces a stacked widget...?

    Quote Originally Posted by ucomesdag View Post
    Is there someway to do it like this dialog->pagesWidget->currentWidget()?
    Of course there is, but the question is whether you are going to use something like this:
    Qt Code:
    1. QString something = (static_cast< SomeConfigPage* >(dialog->pagesWidget->currentWidget()))->ui.someLineEdit->text();
    To copy to clipboard, switch view to plain text mode 
    throughout your code, or do you want to do it in a more elegant way?

  5. #5
    ucomesdag Guest

    Default Re: Acces a stacked widget...?

    What would be more elegant?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Acces a stacked widget...?

    Quote Originally Posted by ucomesdag View Post
    What would be more elegant?
    You can create a ConfigDialog that displays ConfigPages. All ConfigDialog need to know is that what ConfigPages it contains, which one is the current one and which one should become the current one if user selects some item in the list view.

    The ConfigPage should only define an interface. For example it could contain methods like icon() (to get the icon for the list view), title(), read(), write() or similar. For each config page you are going to use, you should subclass ConfigPage and create concrete implementations, like FontConfigPage, ColorConfigPage and so on. Only these subclasses should know what settings they contain and what widgets to use to edit those settings.

    Of course you will need some class to store settings that you can pass to every ConfigPage, for example QSettings.

    This way you can easily reuse ConfigDialog in other places, or control the number of config pages depending on the current user, or have two versions of config dialog: "beginner" mode and "expert" mode, or... And all this you could achieve only by changing the list of pages displayed by the same ConfigDialog class.

  7. The following user says thank you to jacek for this useful post:

    sunil.thaha (28th November 2006)

Similar Threads

  1. QWidget display on 2 stack widget page
    By spawnwj in forum Qt Programming
    Replies: 3
    Last Post: 4th September 2006, 12:07
  2. Pin/Unpin Dock Widget
    By charlesD in forum Newbie
    Replies: 1
    Last Post: 21st June 2006, 06:57
  3. Replies: 4
    Last Post: 24th March 2006, 22:50
  4. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 14:16
  5. advanced split widget
    By vitaly in forum Qt Programming
    Replies: 10
    Last Post: 24th January 2006, 20:00

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.