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.
You can but in my opinion this is a bad idea for the functionality you are trying to implement.
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).
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
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.
I started rewriting a custom widget derived from QScrollArea so:
Qt Code:
{ ..code.. };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
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.
Franco Amato
Deriving or using.. what's the 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.Please can you help me with a little example of zooming in this case?
No difference
I would use a better approach, but I'm sure you understood that I'm unable to do.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 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
Come on, man... Registration date - Nov 2007, 163 posts and no 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?Sometime a very basic example is very usefull starting point.
Qt Code:
w->setGeometry(20, 20, 200, 100);To copy to clipboard, switch view to plain text mode
In my work only write very basic gui...until now
That's my experience.
What I didn't understand is (with an object inherited from QScrollArea)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:
w->setGeometry(20, 20, 200, 100);To copy to clipboard, switch view to plain text mode
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
Viewport is always smaller than the view.
It reimplements QAbstractScrollArea::scrollContentsBy().If so how scrollarea manage scroll bars?
Bookmarks