Page 2 of 2 FirstFirst 12
Results 21 to 40 of 40

Thread: attach more widgets to a QScrollArea

  1. #21
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: attach more widgets to a QScrollArea

    Quote Originally Posted by wysota View Post
    Defintely not

    You are artificially manipulating the size of each child widget which is not a very good idea. Using graphics view or implementing everything as one widget derived from QAbstractScrollArea would be a much better approach.
    Thank you very much.
    Can you give some line the code just to start the widget derived from QAbstractScrollArea?

    Best
    Franco Amato

  2. #22
    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: attach more widgets to a QScrollArea

    I can't give you a complete 10 line sample. I can tell you it is just like any ordinary widget with exception that at each time you only see part of it and the part seen is manipulated using QAbstractScrollArea::scrollContentsBy() that you will need to implement.
    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.


  3. #23
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: attach more widgets to a QScrollArea

    Quote Originally Posted by wysota View Post
    I can't give you a complete 10 line sample. I can tell you it is just like any ordinary widget with exception that at each time you only see part of it and the part seen is manipulated using QAbstractScrollArea::scrollContentsBy() that you will need to implement.
    Why I can not inherits from QScrollArea instead of QAbstractScrollArea?
    Franco Amato

  4. #24
    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: attach more widgets to a QScrollArea

    You can but in my opinion this is a bad idea for the functionality you are trying to implement.
    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.


  5. #25
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: attach more widgets to a QScrollArea

    Quote Originally Posted by wysota View Post
    You can but in my opinion this is a bad idea for the functionality you are trying to implement.

    Is a bit difficult...and I can not find a valid example
    Franco Amato

  6. #26
    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: attach more widgets to a QScrollArea

    What is so difficult in it? As for examples, you have the code of Qt, you also have examples of classes that are derived from classes that are derived from QAbstractScrollArea (like views in Item Views).
    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.


  7. #27
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: attach more widgets to a QScrollArea

    Quote Originally Posted by wysota View Post
    What is so difficult in it? As for examples, you have the code of Qt, you also have examples of classes that are derived from classes that are derived from QAbstractScrollArea (like views in Item Views).
    I can not find such example in my Qt 4.6.0 installation
    Franco Amato

  8. #28
    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: attach more widgets to a QScrollArea

    Quote Originally Posted by franco.amato View Post
    I can not find such example in my Qt 4.6.0 installation
    Qt source code is one big example But you may also look at the "chart" example.
    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.


  9. #29
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: attach more widgets to a QScrollArea

    Quote Originally Posted by wysota View Post
    Qt source code is one big example But you may also look at the "chart" example.
    Thank you very much wysota, but I think what I need is simpler that it appear to be.
    I wrote a routine that draw an audio graph depending on how many audio samples I would display and which is the width of the widget containing the graph.
    So in case of
    • resizing
    • zoomIn
    • zoomOut


    what change (automatically resizing, or manually zooming) is the width of the widget accordingly to that I draw the correct audio wave.
    So I think I don't need to go so deeply reimplementing the method you suggested to me. Maybe I'm wrong.
    What do you think?

    Best Regards
    Franco Amato

  10. #30
    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: attach more widgets to a QScrollArea

    At some point there comes a time where you have to go past your current skills and examples. I think the time has come for you, especially that it seems you have over two years of experience with Qt. You either do it wrong (like you are doing now) and learn nothing or you make some effort, learn and do the thing properly.
    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.


  11. #31
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Post Re: attach more widgets to a QScrollArea

    Quote Originally Posted by wysota View Post
    At some point there comes a time where you have to go past your current skills and examples. I think the time has come for you, especially that it seems you have over two years of experience with Qt. You either do it wrong (like you are doing now) and learn nothing or you make some effort, learn and do the thing properly.
    Already done but seems you didn't agree with my solution
    Franco Amato

  12. #32
    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: attach more widgets to a QScrollArea

    Quote Originally Posted by franco.amato View Post
    Already done but seems you didn't agree with my solution
    Your solution will fall apart once you need to add more functionality to it. Composing your GUI from already existing widgets is not the only possibility, sometimes you need to create a custom widget consisting of something more than just a paint event.
    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.


  13. #33
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: attach more widgets to a QScrollArea

    Quote Originally Posted by wysota View Post
    Your solution will fall apart once you need to add more functionality to it. Composing your GUI from already existing widgets is not the only possibility, sometimes you need to create a custom widget consisting of something more than just a paint event.
    I started rewriting a custom widget derived from QScrollArea so:

    Qt Code:
    1. class WaveDisplay : public QScrollArea
    2. {
    3. ..code..
    4. };
    To copy to clipboard, switch view to plain text mode 

    As I understood until now, QScrollArea show its scroll bars only when the child widgets are bigger than the scrollarea viewport right?
    Here I have a doubt. If my widget inherits from QScrollArea, then it doesn't have a child widget as it's the child widget. So it's size will never
    be bigger than the viewport. It's size will always be equal the viewport and the scroll bars will never appears of I'm saying something foo?

    I hope someone can clarify this to me.

    Best
    Franco Amato

  14. #34
    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: attach more widgets to a QScrollArea

    Deriving from QScrollArea doesn't make sense because eventually you will do the same what you did before. You have to use QAbstractScrollArea and abandon your wave widget class and move its code inside your new class. The point of deriving from QAbstractScrollArea is that you can provide zooming and panning facilities without the need to manipulate widget sizes and layouts. If that's too complicated for you then derive from QScrollArea like you did before but don't use a layout for your scrolled widget and instead position the widgets manually upon every need to do so.
    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.


  15. #35
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: attach more widgets to a QScrollArea

    Quote Originally Posted by wysota View Post
    Deriving from QScrollArea doesn't make sense because eventually you will do the same what you did before. You have to use QAbstractScrollArea and abandon your wave widget class and move its code inside your new class. The point of deriving from QAbstractScrollArea is that you can provide zooming and panning facilities without the need to manipulate widget sizes and layouts. If that's too complicated for you then derive from QScrollArea like you did before but don't use a layout for your scrolled widget and instead position the widgets manually upon every need to do so.
    Hi before I didn't derived from QScrollArea...is what I'm trying to do now. Please can you help me with a little example of zooming in this case?
    My experience is too little at the moment. I'll really appreciate it.

    Best Regards
    Franco Amato

  16. #36
    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: attach more widgets to a QScrollArea

    Quote Originally Posted by franco.amato View Post
    Hi before I didn't derived from QScrollArea...is what I'm trying to do now.
    Deriving or using.. what's the difference?

    Please can you help me with a little example of zooming in this case?
    No, because in my opinion this is a wrong approach. If you insist on doing this, use QWidget::setGeometry() to change the geometry of child widgets.
    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.


  17. #37
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: attach more widgets to a QScrollArea

    Quote Originally Posted by wysota View Post
    Deriving or using.. what's the difference?
    No difference


    No, because in my opinion this is a wrong approach. If you insist on doing this, use QWidget::setGeometry() to change the geometry of child widgets.
    I would use a better approach, but I'm sure you understood that I'm unable to do.
    I have a very poor experience in writing gui and how can I improve it if I don't get help? Sometime a very basic example is very usefull starting point. I did't ask to you to provide a complete software
    Franco Amato

  18. #38
    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: attach more widgets to a QScrollArea

    Quote Originally Posted by franco.amato View Post
    I have a very poor experience in writing gui and how can I improve it if I don't get help?
    Come on, man... Registration date - Nov 2007, 163 posts and no experience?

    Sometime a very basic example is very usefull starting point.
    Always relying on mimicing existing code doesn't lead to extending your skills. What example would you want me to give you? Something like this?
    Qt Code:
    1. QWidget *w = new QWidget(viewport());
    2. w->setGeometry(20, 20, 200, 100);
    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.


  19. #39
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    692
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: attach more widgets to a QScrollArea

    Quote Originally Posted by wysota View Post
    Come on, man... Registration date - Nov 2007, 163 posts and no experience?
    In my work only write very basic gui...until now
    That's my experience.


    Always relying on mimicing existing code doesn't lead to extending your skills. What example would you want me to give you? Something like this?
    Qt Code:
    1. QWidget *w = new QWidget(viewport());
    2. w->setGeometry(20, 20, 200, 100);
    To copy to clipboard, switch view to plain text mode 
    What I didn't understand is (with an object inherited from QScrollArea)
    for example MyWidget : QScrollArea the view port is always = to the width right or not? This is my doubt. If so how scrollarea manage scroll bars?
    Franco Amato

  20. #40
    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: attach more widgets to a QScrollArea

    Viewport is always smaller than the view.
    If so how scrollarea manage scroll bars?
    It reimplements QAbstractScrollArea::scrollContentsBy().
    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. Adding widgets to QScrollArea
    By ser_bur in forum Qt Programming
    Replies: 6
    Last Post: 19th August 2013, 10:38
  2. QSharedMemory won't attach
    By MattPhillips in forum Qt Programming
    Replies: 3
    Last Post: 27th November 2009, 15:45
  3. Replies: 2
    Last Post: 10th March 2008, 20:16
  4. QScrollArea With Custom Widgets
    By VireX in forum Qt Programming
    Replies: 30
    Last Post: 22nd April 2007, 16:48

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.