Results 1 to 7 of 7

Thread: Change Qt version and code stop working

  1. #1
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Change Qt version and code stop working

    Hi all,
    I've just swiched from Qt 4.2.2 to Qt 4.4.3 anf the code I show below does not work anymore. It prints black lines .. any of you knows why it appens ??
    Thank you in advance.
    rmagro

    Qt Code:
    1. QPrinter printer(QPrinter::HighResolution);
    2. printer.setOrientation(QPrinter::Landscape);
    3.  
    4. QTableWidget *nuovaTableWidget = tableWidget;
    5.  
    6. QPrintDialog dlg(&printer, this);
    7.  
    8. if (dlg.exec() == QDialog::Accepted)
    9. {
    10. // calculate the total width/height table would need without scaling
    11. const int rows = nuovaTableWidget->model()->rowCount();
    12. const int cols = nuovaTableWidget->model()->columnCount();
    13.  
    14. double totalWidth = 0.0;
    15.  
    16. for (int c = 0; c < cols; ++c)
    17. {
    18. totalWidth += nuovaTableWidget->columnWidth(c);
    19. }
    20.  
    21. double totalHeight = 0.0;
    22.  
    23. for (int r = 0; r < rows; ++r)
    24. {
    25. totalHeight += nuovaTableWidget->rowHeight(r);
    26. }
    27.  
    28. double totalHeight1;
    29. int numero_pagina = 1;
    30.  
    31. QPixmap pixmap(totalWidth, nuovaTableWidget->horizontalHeader()->height());
    32. QPixmap pixmap1(totalWidth, totalHeight);
    33.  
    34. QPaintEvent event_1(QRect(0, 0, totalWidth, nuovaTableWidget->horizontalHeader()->height()));
    35. QPaintEvent event_2(QRect(0, 0, totalWidth, totalHeight));
    36.  
    37. QPainter::setRedirected(nuovaTableWidget->horizontalHeader()->viewport(), &pixmap);
    38. QApplication::sendEvent(nuovaTableWidget->horizontalHeader()->viewport(), &event_1);
    39. QPainter::restoreRedirected(nuovaTableWidget->horizontalHeader()->viewport());
    40.  
    41. QPainter::setRedirected(nuovaTableWidget->viewport(), &pixmap1);
    42. QApplication::sendEvent(nuovaTableWidget->viewport(), &event_2);
    43. QPainter::restoreRedirected(nuovaTableWidget->viewport());
    44.  
    45. // print scaled pixmap
    46. QPainter painter(&printer);
    47.  
    48. QDateTime dataDiOggi = QDateTime::currentDateTime();
    49. QString dataDiOggiStringa = dataDiOggi.toString("dd.MM.yyyy hh:mm:ss");
    50.  
    51. painter.scale(4.5,4.5);
    52. painter.drawPixmap(0, 100, totalWidth, nuovaTableWidget->horizontalHeader()->height(), pixmap);
    53. painter.drawPixmap(0, 100+nuovaTableWidget->horizontalHeader()->height(), totalWidth, totalHeight, pixmap1);
    54. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Change Qt version and code stop working

    No one faced with this problem guys or any clue ?
    Many thanks
    rmagro

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,356
    Thanks
    3
    Thanked 5,010 Times in 4,789 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: Change Qt version and code stop working

    Usually when people come with problems like that at the end it occurs that in fact apart from changing Qt version they also changed (broke) their code or its environment (i.e. missing image plugins).
    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.


  4. #4
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Change Qt version and code stop working

    It not absolutely my case. If I indeed switch back to Qt4.2.2 it start working again perfectly .. How come ??
    Is there an alternative way (better way) to do the same ??
    Thx
    rmagro

  5. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Change Qt version and code stop working

    Please provide a minimal compiling example of your problem.

  6. #6
    Join Date
    Jun 2007
    Location
    italy
    Posts
    126
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Change Qt version and code stop working

    Hi Guys,
    at the following link you'll find a compiled example of my program:
    www.businesskey.it/BIN.zip
    To use it just run the parser.exe file, select the LicenzaDiKe.pdf.p7m file and wait a little bit till the table is shown.
    Then click the "stampa" button to see how the funtion I posted print the line..
    Many thanks for your suggestion and kind availability
    rmagro

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,356
    Thanks
    3
    Thanked 5,010 Times in 4,789 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: Change Qt version and code stop working

    I think tbscope meant a minimal (i.e. 30 lines of code) and compilable (not "compiled") 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.


Similar Threads

  1. Replies: 7
    Last Post: 12th September 2012, 06:42
  2. Moving QObject to QThread causes signals to stop working
    By Ban-chan in forum Qt Programming
    Replies: 8
    Last Post: 13th July 2010, 21:39
  3. Replies: 0
    Last Post: 11th August 2009, 09:38
  4. Replies: 5
    Last Post: 5th October 2008, 05:12
  5. Getting VERSION from code?
    By sdfisher in forum Qt Programming
    Replies: 7
    Last Post: 30th August 2007, 01:15

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.