Results 1 to 7 of 7

Thread: Some questions on porting apps to Window$

  1. #1
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Some questions on porting apps to Window$

    Hi everybody,
    new day new questions; cause some people are yet using gates' OS i am porting my application to this; since my application is 100% QT4.3 dipendent I have downloaded QT/Windows Open Source Edition (self-extracting installer).

    Then I have recompiled my source; from my experience here are my questions:
    1. Who explains me this strange behaviour?
      The folloeing code:
      Qt Code:
      1. #include <QtGui>
      2. #include <QSqlDatabase>
      3. #include "maindialog.h"
      4.  
      5. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
      6.  
      7. MainDialog::MainDialog(QWidget *parent)
      8. :QDialog(parent)
      9. {
      10. ...
      11. if(!createConnection())
      12. return;
      13. ...
      14. }
      15.  
      16. bool MainDialog::createConnection()
      17. {
      18. db.setDatabaseName(QApplication::applicationDirPath() + "/gmc_db");
      19. if (!db.open()) {
      20. QMessageBox::critical(0, qApp->tr("Cannot open database"),
      21. qApp->tr("Unable to establish a database connection.\n"
      22. "This program needs SQLite support. Please read "
      23. "the Qt SQL driver documentation for information how "
      24. "to build it.\n\n"
      25. "Click Cancel to exit."), QMessageBox::Cancel);
      26. return false;
      27. }
      28. return true;
      29. }
      To copy to clipboard, switch view to plain text mode 

      gives error during execution on db.open() (as it can't find the database file, while it exist and is in the same directory as the exe).

      If I move, instead, the row

      Qt Code:
      1. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
      To copy to clipboard, switch view to plain text mode 

      in createConnection() function it works good (in linux works in both situations).
    2. The aspect of the text in the windows version is worst than in linux; it appears bigger and aliased; why? Is related to windows itself or to qt libraries?

      If I have this code:

      Qt Code:
      1. QFont Strings::totalscoreFont()
      2. {
      3. QFont font;
      4. font.setStyleStrategy(QFont::PreferAntialias);
      5. font.setStyleStrategy(QFont::ForceOutline);
      6. font.setPixelSize(60);
      7. font.setBold(true);
      8. font.setFamily("Monofonto");
      9.  
      10. return font;
      11. }
      To copy to clipboard, switch view to plain text mode 

      How can i change it so during compilation under windows it uses different fontfamily and size?
    3. If i want give the compiled exe to my friends they need qt4.3 installed, doesn't they? Or can I include some qt's dll with my code (my application will be licensed under GPL).


    Thanks for helping me,
    Giuseppe CalÃ

  2. The following user says thank you to jiveaxe for this useful post:


  3. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Some questions on porting apps to Window$

    Quote Originally Posted by jiveaxe View Post
    If I move, instead, the row

    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    To copy to clipboard, switch view to plain text mode 

    in createConnection() function it works good (in linux works in both situations).
    You shouldn't create any Qt objects before you instantiate QApplication (or QCoreApplication). In this case it doesn't work, because you try to use the QSQLITE driver before it was loaded by QApplication. On Linux it probably works, because you have this driver compiled into Qt.

    Quote Originally Posted by jiveaxe View Post
    font.setFamily("Monofonto");
    Are you sure that this font is available on windows? If not Qt will use a different one.

    Quote Originally Posted by jiveaxe View Post
    How can i change it so during compilation under windows it uses different fontfamily and size?
    You can use Q_OS_WIN32 macro.

    Quote Originally Posted by jiveaxe View Post
    If i want give the compiled exe to my friends they need qt4.3 installed, doesn't they? Or can I include some qt's dll with my code (my application will be licensed under GPL).
    They don't have to install anything, just give them all required DLLs and plugins.

    http://doc.trolltech.com/4.3/deployment.html
    http://doc.trolltech.com/4.3/deployment-windows.html

  4. The following 2 users say thank you to jacek for this useful post:

    jiveaxe (2nd November 2007)

  5. #3
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Some questions on porting apps to Window$

    You can use Q_OS_WIN32 macro.
    Is this right?

    Qt Code:
    1. QFont Strings::totalscoreFont()
    2. {
    3. QFont font;
    4. font.setStyleStrategy(QFont::PreferAntialias);
    5. font.setStyleStrategy(QFont::ForceOutline);
    6. font.setBold(true);
    7. #ifdef Q_OS_WIN32
    8. font.setPixelSize(60);
    9. font.setFamily("Verdana");
    10. #else
    11. font.setPixelSize(50);
    12. font.setFamily("Monofonto");
    13. #endif
    14.  
    15. return font;
    16. }
    To copy to clipboard, switch view to plain text mode 

    Have I to modify also the .pro file?

    They don't have to install anything, just give them all required DLLs and plugins.
    So in my case I have to add to my package QtCore4.dll, QtGui4.dll, QtSql4.dll, right?

    Regards
    Giuseppe CalÃ

  6. The following user says thank you to jiveaxe for this useful post:


  7. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Some questions on porting apps to Window$

    Quote Originally Posted by jiveaxe View Post
    Is this right?
    It looks OK.

    Quote Originally Posted by jiveaxe View Post
    Have I to modify also the .pro file?
    No, you don't have to.

    Quote Originally Posted by jiveaxe View Post
    So in my case I have to add to my package QtCore4.dll, QtGui4.dll, QtSql4.dll, right?
    And a sqldrivers subdirectory with QSQLITE driver.

  8. #5
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Some questions on porting apps to Window$

    Quote Originally Posted by jacek View Post
    And a sqldrivers subdirectory with QSQLITE driver.
    Which should be libqsqlite4.a, qsqlite4.dll.

    Ok, understood.

    Thanks
    Giuseppe CalÃ

  9. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Some questions on porting apps to Window$

    Quote Originally Posted by jiveaxe View Post
    Which should be libqsqlite4.a, qsqlite4.dll.
    You only have to deploy the DLL file.

  10. #7
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Some questions on porting apps to Window$

    Ok, now it's all clear.

    Bye
    Giuseppe CalÃ

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.