Results 1 to 12 of 12

Thread: QStackedWidget fill Postscript image And scroll problem

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QStackedWidget fill Postscript image And scroll problem

    I wand to display one ore moore QStackedWidget to paint inside a postscript image or a pdf...

    the device to paint work but how i can enable scroll this QStackedWidget


    Qt Code:
    1. class QPdf : public QMainWindow
    2. {
    3.  
    4. //
    5. public:
    6. QPdf(const QString pdf_file) {
    7.  
    8. setWindowTitle ( tr( "Pdf and Postscript display.. file %1 " ).arg(pdf_file));
    9. pages = 0;
    10. spage = new QStackedWidget(this);
    11.  
    12. GString *ownerPW, *userPW;
    13. doc = new PDFDoc(new GString(pdf_file),ownerPW, userPW);
    14.  
    15. if (doc->isOk()) {
    16. qDebug() << "### doc->isOk() "<< doc->isOk();
    17. pages = doc->getNumPages();
    18. qDebug() << "### pages "<< pages;
    19.  
    20. for (int i=0;i<pages;i++) {
    21. int nowrender = i + 1; /* render page pdf nr. */
    22. qDebug() << "### page item "<< nowrender;
    23. SplashOutputDev *onepdf = new SplashOutputDev(QSize(doc->getPageWidth(nowrender),doc->getPageHeight(nowrender)));
    24. /////onepdf->InPaint(doc->getBitmap(nowrender));
    25. spage->addWidget(onepdf);
    26. }
    27.  
    28. }
    29. setCentralWidget ( spage );
    30. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStackedWidget fill Postscript image And scroll problem

    Add the SplashOutputDev widgets to QScrollAreas, and add these scroll areas to the QStackedWidget, instead of adding directly the SplashOutputDev widgets.

    This way you will get your scroll.

    Regards

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStackedWidget fill Postscript image And scroll problem

    You can use QScrollArea::sertWidget() to achieve this.

    BTW: are you using XPdf?

    Regards

  4. #4
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QStackedWidget fill Postscript image And scroll problem

    Quote Originally Posted by marcel View Post
    You can use QScrollArea::sertWidget() to achieve this.

    BTW: are you using XPdf?
    Original is XPDF but i take from opie-1.2.2.tr qt3 (qtfriendly)

    http://opie.handhelds.org/

    Yes .. :-) is running on window on mingw compiler ... i wand to diplay fast latex result whittout acroread and paint inside point/pixel scala....

    Have you a ready QT4 class to use? for my use? or a better doc from XPDF?

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStackedWidget fill Postscript image And scroll problem

    No, I was just asking... I thought maybe there is another pdf library out there
    I am working on a vector-drawing app and I plan to embed xpdf( for pdf loading ) sometimes in a near future.

    Have you tried using QScrollArea?

  6. #6
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QStackedWidget fill Postscript image And scroll problem

    Quote Originally Posted by marcel View Post
    No, I was just asking... I thought maybe there is another pdf library out there
    I am working on a vector-drawing app and I plan to embed xpdf( for pdf loading ) sometimes in a near future.

    Have you tried using QScrollArea?
    Yes ... but not runn .... i suppose i must rewrite a wrapper to paint inside ...
    but now here is europe time ... and i quit my code.... otherwise i paint the QScrollArea...

    Qt Code:
    1. /* class SplashOutputDev : public QWidget */
    2.  
    3. SplashOutputDev::SplashOutputDev( QSize qo )
    4. {
    5. p = qo;
    6. qDebug() << "### size "<< p;
    7. scroll = new QScrollArea();
    8. scroll->setBackgroundRole(QPalette::Dark);
    9. scroll->ensureVisible(p.width(),p.height(),100,100);
    10. scroll->setWidget(this);
    11. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStackedWidget fill Postscript image And scroll problem

    No, this is not what i meant...
    Try this:
    Qt Code:
    1. class QPdf : public QMainWindow
    2. {
    3.  
    4. //
    5. public:
    6. QPdf(const QString pdf_file) {
    7.  
    8. setWindowTitle ( tr( "Pdf and Postscript display.. file %1 " ).arg(pdf_file));
    9. pages = 0;
    10. spage = new QStackedWidget(this);
    11.  
    12. GString *ownerPW, *userPW;
    13. doc = new PDFDoc(new GString(pdf_file),ownerPW, userPW);
    14.  
    15. if (doc->isOk()) {
    16. qDebug() << "### doc->isOk() "<< doc->isOk();
    17. pages = doc->getNumPages();
    18. qDebug() << "### pages "<< pages;
    19.  
    20. for (int i=0;i<pages;i++) {
    21. int nowrender = i + 1; /* render page pdf nr. */
    22. qDebug() << "### page item "<< nowrender;
    23. SplashOutputDev *onepdf = new SplashOutputDev(QSize(doc->getPageWidth(nowrender),doc->getPageHeight(nowrender)));
    24. QScrollArea* scrollarea = new QScrollArea( spage );
    25. scrollarea->setWidget( onepdf );
    26. /////onepdf->InPaint(doc->getBitmap(nowrender));
    27. spage->addWidget(scrollarea);
    28. }
    29.  
    30. }
    31. setCentralWidget ( spage );
    32. }
    To copy to clipboard, switch view to plain text mode 
    Here I add the SplashOutputDev widget to a scroll area, and then I add the scroll area to the QStackedWidget.
    It should work like this.

    Regards

  8. #8
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStackedWidget fill Postscript image And scroll problem

    There is no need to paint to a scroll area. You can keep your code as it is, and ad scroll areas with minimal changes.

    Regards

  9. #9
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QStackedWidget fill Postscript image And scroll problem

    Quote Originally Posted by marcel View Post
    There is no need to paint to a scroll area. You can keep your code as it is, and ad scroll areas with minimal changes.

    Regards
    I look on my image displayer that display a widget and inside image on a FlowLayout that runn and scroll is visible... to append and remove image ... on qlist ...*class

    but now i must display page and not tumbnail ....

    Qt Code:
    1. void Image_Base::Load_Connector() {
    2.  
    3. comio = new Comandi(); /* top left widget command button*/
    4.  
    5. scroll = new QScrollArea(this);
    6. scroll->setBackgroundRole(QPalette::Dark);
    7. scroll->setMinimumWidth(500);
    8. wrapper = new QWidget(this);
    9. flow = new FlowLayout(wrapper);
    10. flow ->addWidget(comio);
    11. wrapper->setLayout(flow);
    12. scroll->setWidget(wrapper);
    13.  
    14. }
    15.  
    16. flow ->addWidget(imagedisplay);
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStackedWidget fill Postscript image And scroll problem

    Yes, and the code I've shown you should work just fine.
    Isn't SplashOutputDev the widget in which you are rendering the current pdf page?
    I assumed it was when I answered. Adding it to a scroll area and then adding the scroll area to the stacked widget will work.

    You will not need any additional layouts or anything else...

    Regards

  11. #11
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QStackedWidget fill Postscript image And scroll problem

    Quote Originally Posted by marcel View Post
    Yes, and the code I've shown you should work just fine.
    Isn't SplashOutputDev the widget in which you are rendering the current pdf page?
    I assumed it was when I answered. Adding it to a scroll area and then adding the scroll area to the stacked widget will work.

    You will not need any additional layouts or anything else...

    Regards
    now is run tanks...

    Qt Code:
    1. public:
    2. QPdf(const QString pdf_file) {
    3.  
    4. setWindowTitle ( tr( "Pdf display.. file %1 " ).arg(pdf_file));
    5. pages = 0;
    6. spage = new QStackedWidget(this);
    7.  
    8. GString *ownerPW, *userPW;
    9. doc = new PDFDoc(new GString(pdf_file),ownerPW, userPW);
    10.  
    11. if (userPW) {
    12. delete userPW;
    13. }
    14. if (ownerPW) {
    15. delete ownerPW;
    16. }
    17. if (doc->isOk()) {
    18. qDebug() << "### doc->isOk() "<< doc->isOk();
    19. pages = doc->getNumPages();
    20. qDebug() << "### pages "<< pages;
    21.  
    22. for (int i=0;i<pages;i++) {
    23. int nowrender = i + 1; /* render page pdf nr. */
    24. qDebug() << "### page item "<< nowrender;
    25. QScrollArea *src = new QScrollArea(spage);
    26. SplashOutputDev *onepdf = new SplashOutputDev(src);
    27. /////onepdf->InPaint(doc->getBitmap(nowrender));
    28. onepdf->SetPage(nowrender,QSize(doc->getPageWidth(nowrender),doc->getPageHeight(nowrender)));
    29. src->setWidget(onepdf);
    30. onepdf->setMinimumHeight(doc->getPageHeight(nowrender) + 1);
    31. onepdf->setMinimumWidth(doc->getPageHeight(nowrender) + 50);
    32. src->setBackgroundRole(QPalette::Dark);
    33. spage->addWidget(src);
    34. }
    35.  
    36. spage->setCurrentIndex(0); /* jump first */
    37.  
    38. }
    39. setCentralWidget ( spage );
    40. }
    To copy to clipboard, switch view to plain text mode 

  12. #12
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QStackedWidget fill Postscript image And scroll problem

    Nice...
    Qt Code:
    1. onepdf->SetPage(nowrender,QSize(doc->getPageWidth(nowrender),doc->getPageHeight(nowrender)));
    2. src->setWidget(onepdf);
    3. onepdf->setMinimumHeight(doc->getPageHeight(nowrender) + 1);
    4. onepdf->setMinimumWidth(doc->getPageHeight(nowrender) + 50);
    5. src->setBackgroundRole(QPalette::Dark);
    To copy to clipboard, switch view to plain text mode 
    I thought that:
    Qt Code:
    1. onepdf->SetPage(nowrender,QSize(doc->getPageWidth(nowrender),doc->getPageHeight(nowrender)));
    To copy to clipboard, switch view to plain text mode 
    was already setting the size of onepdf.

    EDIT:
    Shouldn't you use:
    Qt Code:
    1. onepdf->setMinimumHeight(doc->getPageWidth(nowrender) + 1);
    2. onepdf->setMinimumWidth(doc->getPageHeight(nowrender) + 50);
    To copy to clipboard, switch view to plain text mode 
    You were setting page height for both minimum width and height.
    Regards
    Last edited by marcel; 22nd April 2007 at 09:38.

Similar Threads

  1. Big image, how to scroll to see it ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2007, 13:27
  2. Scroll large image in game
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 11th August 2006, 23:06

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.