Results 1 to 8 of 8

Thread: (1) Sub- and superscripts Windows & (2) deploying programs

  1. #1
    Join Date
    Aug 2011
    Location
    the Netherlands
    Posts
    6
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default (1) Sub- and superscripts Windows & (2) deploying programs

    Over the last year we have been working on a user interface for a simple meteorological model, to be used in some courses here at the Wageningen University. One of our wishes was to create a cross-platform program but although we have succeeded in this, there are still a few open problems:

    1) Sub- and superscripts, mainly on Windows (XP/7):
    In the interface we are using a lot of sub- and superscripts (and special characters), both in simple QLabels as in a QTreeWidget (see image below). Initially we used Unicode symbols which worked well in our development environment (both Linux and OS X), but unfortunately a lot of unicode symbols seem to be missing on Windows (e.g. a superscript minus). For the QLabels we were able to bypass this problem by formatting the labels in html (the ugly solution?), unfortunately in the QTreeWidget this is a bit difficult. We 'solved' this by using a normal minus instead of a superscript minus, but this is off course an ugly and temporary fix.
    Does anyone know a good method to work with special characters in Qt, suitable for using in QLabels, QTreeWidgets, etc on OS X, Linux and Windows?

    2) Deploying programs for Windows:
    To create a stand-alone package for distribution I statically compiled QtCreator as described in many online tutorials. This is working, I only have to attach a few .dll files and thats it. However it took me quite some time to statically compile QtCreator, basically trial-and-error with disabling ever more options in the compile flags until it was working. Now I have to do this again, this time on Windows 7, and so far I haven't succeeded in compiling QtCreator To me this method of using a static compilation seems unnecessarily difficult; the compilation takes half a (working) day and (at least here) it often fails.
    Am I missing something? Can this be done easier? Or does everybody who wants to make even the most simple program have to go through this 'hell'? For OS X there is a nice "Mac Deployment Tool", is there something similar for Windows?

    Any answers will be greatly appreciated!
    Cheers, Bart vS


  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: (1) Sub- and superscripts Windows & (2) deploying programs

    1) Is it possible that the windows font (or the font you are using on windows) does not support that unicode chars? Have you test it with the same font? If so, I have no clue why, but as a work around you can use html (which in my opinion isn't so ugly) and you can also use it for the items ... but you have to create your own item delegate. To render the strings with html use QTextDocument and set the html there, then render it to the QPainter via QTextDocument::drawContents(). Some work but not so much for pure string items.

    2) Why you have to link static. Isn't a dynamic linked application possible. For that you could provide an (single) install.exe. See NSIS Installer or BitRock etc.

  3. The following user says thank you to Lykurg for this useful post:

    julietbravo (11th August 2011)

  4. #3
    Join Date
    Aug 2011
    Location
    the Netherlands
    Posts
    6
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: (1) Sub- and superscripts Windows & (2) deploying programs

    Thanks for your fast reply Lykurg!

    1) Most fonts used in Windows seem to have a limited character set where some characters indeed simply don't exist. I'll have to look into your proposed solution; all the data in the QTreeWidget is loaded from an object (not 'hard-coded' in the QTreeWidget) so perhaps I can put everything (or at least where needed) in html and load it through the sequence you suggested.

    2) I tried making a stand-alone package before using a non-static compiled version of QtCreator but then I ended up with a huge nested list of dependencies (a.dll which depends on b.dll which depends on c.dll,d.dll.e.dll, etc.). I checked this with a tool called "Dependency Walker". How can I best solve this dependency problem? For me the list of dependencies (based on the output of the Dependency Walker) seemed endless...

    *EDIT* Disregard my last question, I just found a quite extensive explanation about these things in the wiki of this website, I'll look through this before bothering you people with newbie questions

    Again, thanks in advance
    Bart
    Last edited by julietbravo; 10th August 2011 at 23:13.

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: (1) Sub- and superscripts Windows & (2) deploying programs

    Hi,

    some further notes/ideas:

    1) Before changing all to html, take a font, which supports the unicode symbols you use, and try it on windows. If that works you can deploy the font alongside your application without the need to actually install the font. Put the font in the qrc file and load it at runtime via QFontDatabase::addApplicationFontFromData().

    2) Most of the dependencies you see are covered by Windows 7. If you don't use any further libraries you only have to bundle Qt(core|gui|sql).dll and the one of your compiler. That's all. (Possible some image plugins.) I guess you already have seen that: http://doc.qt.nokia.com/latest/deployment-windows.html.

    And why do you want to deploy Qt Creator? It is only the editor and your application don't need it.

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

    julietbravo (11th August 2011)

  7. #5
    Join Date
    Aug 2011
    Location
    the Netherlands
    Posts
    6
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: (1) Sub- and superscripts Windows & (2) deploying programs

    Hi,

    1) We deliberately chose to work with the default fonts under Windows/OSX/Linux; for instance, by default I use the Ubuntu font under OpenSUSE and I always hate it when a program forces me to use, lets say, Comic Sans . I'll try the solution with html; if it is working we can use this on Windows/OSX/Linux (in the latter two we were also missing e.g. a superscript "3", so using html will sove some additional problems).

    2) My apologies if I was unclear, we don't want to deploy QtCreator, only our little application . I just did a fresh install of QtCreator (under Windows 7) and compiled (release) the program again. Moved the application to a new directory, included QtCore4.dll, mingwm10.dll, QtGui4.dll and next tried to fix the dependencies, needing the additional files: IEShims.dll (which was located in the Program files/internet explorer directory, I guess this is needed for the html that I use?), libgcc_s_dw2-1.dll and msvcr90.dll.

    If I pull this combination through the dependency walker it gives me a warning ("error: at lest one module has an unresolved import due to a missing export function in an implicitly dependent module") and get a lot of missing functions (_Z4endlR11QtTextStream, _Z5qFreePv and about 100 more of these) from QtCore4.dll as QtGui4.dll depends on this file..

    This is basically the problem I had before, after which I switched to a statically compiled version of QtCreator. Then I only needed to include Ieshims.dll, libgcc_s_dw2-1.dll and mingwm10.dll to get our little program working on a different (Qt-clean) system.


    If you need additional information, let me know.
    Thanks, Bart

  8. #6
    Join Date
    Aug 2011
    Location
    the Netherlands
    Posts
    6
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: (1) Sub- and superscripts Windows & (2) deploying programs

    As for problem 1); at the moment I'm filling the QtreeWidget like this:

    Qt Code:
    1. for (int n=0; n<advancedtreegroups.size(); n++)
    2. {
    3. QTreeWidgetItem *treegroup = new QTreeWidgetItem;
    4. treegroup->setText(0,advancedtreegroups.value(n));
    5. ui->advancedplottree->addTopLevelItem(treegroup);
    6. if (n == 0)
    7. ui->advancedplottree->expandItem(treegroup);
    8.  
    9. for (int i=0; i<allvariables.value(n).size(); i++)
    10. {
    11. outputvar item = allvariables.value(n).value(i);
    12. treeitem->setCheckState(1,Qt::Unchecked);
    13.  
    14. if (advancedtreegroups.value(n) != "Vertical profiles")
    15. treeitem->setCheckState(2,Qt::Unchecked);
    16.  
    17. QString variable = QString::fromUtf8(item.name.c_str()) + " [" + QString::fromUtf8(item.unit.c_str()) + "]";
    18. QString description = QString::fromUtf8(item.description.c_str());
    19. QString id = QString::fromUtf8(item.id.c_str());
    20.  
    21. treeitem->setText(0, variable);
    22. treeitem->setText(3, description);
    23. treeitem->setText(4, id);
    24.  
    25. treegroup->addChild(treeitem);
    26. }
    27. }
    To copy to clipboard, switch view to plain text mode 

    What should be the way to go? Given this structure, what would be the simplest solution to render some html in a QTreeWidgetItem at a given position/column?

    I can create a QTextDocument and put some html in it:
    Qt Code:
    1. abc.setHtml("<html>m s<sup>-1</sup></html>");
    To copy to clipboard, switch view to plain text mode 

    But then I'm completely stuck at how to continue

    ~Bart

  9. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: (1) Sub- and superscripts Windows & (2) deploying programs

    Ok, that's my last present before I go on vacation tomorrow. It is not perfect, one can do a lot of optimizations, but that's all homework for you
    Qt Code:
    1. #include <QtGui>
    2.  
    3.  
    4. class MyDelegate : public QStyledItemDelegate
    5. {
    6. public:
    7. MyDelegate(QObject* parent = 0)
    8. : QStyledItemDelegate(parent) {};
    9.  
    10. void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
    11. {
    12. // you could also do a quick reg exp to check for
    13. // HTML tags.
    14. if (true == index.data(Qt::UserRole + 1234).toBool())
    15. {
    16. td.setPageSize(option.rect.size());
    17. td.setTextWidth(option.rect.width());
    18. td.setDefaultFont(option.font);
    19. td.setDocumentMargin(0);
    20. td.setHtml(index.data().toString());
    21. painter->translate(option.rect.topLeft());
    22. td.drawContents(painter, QRect(QPoint(0,0), option.rect.size()));
    23. painter->translate(-option.rect.topLeft());
    24. }
    25. else
    26. QStyledItemDelegate::paint(painter, option, index);
    27. }
    28.  
    29. };
    30.  
    31. int main(int argc, char *argv[])
    32. {
    33. QApplication a(argc, argv);
    34.  
    35. tw.setColumnCount(1);
    36. tw.setItemDelegate(new MyDelegate(&tw));
    37.  
    38. QList<QTreeWidgetItem *> items;
    39.  
    40. it = new QTreeWidgetItem;
    41. it->setText(0, "plain Text");
    42. items << it;
    43.  
    44. it = new QTreeWidgetItem;
    45. it->setText(0, "m s<sup>-1</sup>");
    46. it->setData(0, Qt::UserRole + 1234, true);
    47. // you can choose any value for 1234
    48. // this just tells if the item should
    49. // rendered as HTML
    50. items << it;
    51.  
    52. it = new QTreeWidgetItem;
    53. it->setText(0, "m s<sup>-3</sup>");
    54. it->setData(0, Qt::UserRole + 1234, true);
    55. items << it;
    56.  
    57. it = new QTreeWidgetItem;
    58. it->setText(0, "m s<sup>-1</sup>");
    59. it->setData(0, Qt::UserRole + 1234, false);
    60. items << it;
    61.  
    62. tw.insertTopLevelItems(0, items);
    63.  
    64. tw.show();
    65.  
    66. return a.exec();
    67. }
    To copy to clipboard, switch view to plain text mode 

  10. The following user says thank you to Lykurg for this useful post:

    julietbravo (11th August 2011)

  11. #8
    Join Date
    Aug 2011
    Location
    the Netherlands
    Posts
    6
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: (1) Sub- and superscripts Windows & (2) deploying programs

    Looks like I have some studying to do Great, thanks a lot and have a nice vacation!!

Similar Threads

  1. Qt for programs on Windows CE
    By kyut in forum Newbie
    Replies: 20
    Last Post: 3rd March 2011, 12:32
  2. Trouble deploying on Windows
    By kiss-o-matic in forum Installation and Deployment
    Replies: 6
    Last Post: 17th October 2010, 06:42
  3. Deploying first Windows app.... compiled... now what.
    By kiss-o-matic in forum Installation and Deployment
    Replies: 3
    Last Post: 14th October 2010, 15:05
  4. How to do superscripts and subscripts in a QLineEdit?
    By aarunt1 in forum Qt Programming
    Replies: 0
    Last Post: 10th March 2010, 11:49
  5. Deploying on Windows
    By GianMarco in forum Installation and Deployment
    Replies: 6
    Last Post: 18th November 2009, 07:13

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
  •  
Qt is a trademark of The Qt Company.