PDA

View Full Version : Increase the maximum limit of Qscroll area



anupam
14th June 2013, 13:10
I have to print the hard disk values in a widget in the form of hexadecimal , just like in any hex editor.
I am getting problem with the maximum size of QScrollarea. Can I customize the size of qscroll area because I have to display the disk in a single scroll area , from sector 0 to the last sector of the disk . The disk size is 500GB.

Santosh Reddy
14th June 2013, 13:15
I am getting problem with the maximum size of QScrollarea.
What is the problem?

wysota
14th June 2013, 17:09
I am getting problem with the maximum size of QScrollarea. Can I customize the size of qscroll area because I have to display the disk in a single scroll area , from sector 0 to the last sector of the disk . The disk size is 500GB.
Did you calculate how much RAM is needed to display all that data?

anupam
17th June 2013, 12:33
I have to show the data of whole hard disk in the form of hexadecimal just like
:-
000000 50 4b 03 04 0a 00 00 00 00 00 e5 5e 91 42 00 00
000010 00 00 00 00 00 00 00 00 00 00 0d 00 10 00 4d 64
.
.
.
.
121022000020 69 5f 31 36 5f 41 70 72 69 6c 2f 55 58 0c 00 22


so I have used the QScroll area & draw the text with QPainter .
Here 000000 , 0000010, 000020 to 121022000020 are the offset & next column is the corresponding byte for the offset position.
So after increasing the range of integer the scroll area stops the showing the line .
Because QPatiner takes maximum limit of integer in height() so this can also be a problem ....

My problem is that , I have to show all hard disk data in a single scroll area..
Please help me..
Thanks in advance...

wysota
17th June 2013, 13:10
Displaying 500GB in hexadecimal form requires at least 2TB of memory (since each byte is converted into two hex digits and each character in QString is encoded using 16 bits). Does your machine have that much memory? Unless you know where to buy memory chips sized 512GB or more (and have a machine capable of using that much memory), you can't do it.

The proper approach is to use QAbstractScrollArea, subclass it and reimplement the painting routine to only draw the part of the disk that you are currently displaying.

anupam
17th June 2013, 13:28
QAbstractScrollArea does not take the value outside the range of integer, this is the main problem,
& QPainter is also not painting outside of range of integer...
Can I customiz the scroll area to take qint64 As well as QPainter..

I just want to make a disk editor..

wysota
17th June 2013, 14:03
QAbstractScrollArea does not take the value outside the range of integer, this is the main problem,
No, it is not a problem.

512GB = 512 * 2^30 = 2^39
MAXINT = 2^31

hence

granularity is 2^39 / 2^31 = 2^8 = 256

hence scrolling "by 1" moves the content "by 256"

2^8 / 16 = 2^8 / 2^4 = 2^4 = 16

hence scrolling "by 1" moves the content by 16 lines hence you have to guarantee that you can display at least 16 lines at once (asuming the font to be around 10pt high you need your viewport to be about 200pt or larger which is easily achievable). If that's not possible, implement your own scrollbar which takes qint64 as the value and your own abstract scroll area that uses your scrollbar class.


QPainter is also not painting outside of range of integer...
You are painting with the size of the viewport which is less than the height of your screen.

anupam
18th June 2013, 05:20
Thanks , I am going to implement the first solution .