Re: [Interest] lrelease before compiling qrc

2023-11-07 Thread Robert Hairgrove via Interest

On 07.11.23 15:54, Robert Hairgrove via Interest wrote:

a very small subset for errors...

... which I do add to the application's resources.
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] lrelease before compiling qrc

2023-11-07 Thread Robert Hairgrove via Interest

On 07.11.23 14:59, Petric Frank wrote:

Hello,

in my app i have translation files. I added them to the qrc-file because i
want to load the translations from resource:

 app-de_DE.qm
 app-en_US.qm

They are are generated from *.ts files. In *.pro i added

 CONFIG += lrelease
 TRANSLATIONS = app-de_DE.ts \
app-en_US.ts

The problem is when i build the app it breaks at compiling the qrc-file:
   make: *** No rule to make target '../app/app-de_DE.qm', needed by
'qrc_app.cpp'.  Stop.

I think that the lrelease step comes too late.

So the question is how to overcome this ?
For example executing lrelease earlier - maybe at first - at make run. How i
have to modify the *.pro file ?

kind regards
   Petric


I always thought that 'lupdate' and 'lrelease' needed to run as external 
applications? Adding it to the CONFIG variable will most likely not do 
anything.


At the very least you will need to copy the *.qm files from their 
default location to the resource "qrc" folder (or a subfolder of that) 
and add them at least once to the resource file, otherwise the resource 
compiler will not find them.


If the translation files are not too big and hardly ever change, you can 
do it this way. However, once you start supporting more than one or two 
languages it becomes very difficult to manage if they are embedded into 
the application.


Personally, I prefer to load the translations at runtime from the 
application folder and use a very small subset for errors that might 
occur at startup  -- for example, not being able to find the *.qm file 
at runtime... :)


Using Qt Creator you can add 'lrelease' as a custom build step (click on 
"Project" in the left panel, then "Build & Run" to access this option.) 
You can move it up or down depending on whether it should run before or 
after the actual build.


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] L Word

2021-04-30 Thread Robert Hairgrove

There IS the other forum at https://forum.qt.io/ ...

It has lots of subforums which would seem adequate for off-topic content 
as long as it even remotely concerns Qt.


Bob

--

On 30.04.21 17:20, Jason H wrote:
Maybe the answer is another mailing list, "qt-offtopic" or whatever, 
and we can say that such hyperbole is appropriate there, but not here. 
I do appreciate the comments that for people looking for a dense, 
tenchical resource, the hyperbole is diluting.
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Embedding language translation as resource

2021-04-26 Thread Robert Hairgrove
You need to load the ".qm" file which is the binary generated by running 
lrelease, not the ".ts" file.


In addition to your "hello_la.qm" file, you might want to load Qt's 
"qtbase_la.qm" file (if there is one) which contains translations for 
most of the built-in GUI elements.


HTH, Bob

--

On 27.04.21 07:06, Nicholas Yue wrote:

Hi,

  I am trying to embed translation file as a resource but when I run 
the compiled program, it fails to load the translation


ERROR: Translation failure to load

main.cpp
***
#include 
#include 
#include 
#include 

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QString appDir = QCoreApplication::applicationDirPath();
    QTranslator translator;
    QString translationDir = appDir + "/translation";
    // if (translator.load("hellotr_la",translationDir)) {
if (translator.load(":/language/hellotr_la.ts")) {
    app.installTranslator();
    } else {
    std::cerr << "ERROR: Translation failure to load" << std::endl;
    }

    QPushButton hello(QPushButton::tr("Hello world!"));
    hello.resize(100, 30);

    hello.show();
    return app.exec();
}

hellotr_lang.qrc
**


    hellotr_la.ts



hellotr_la.ts
*




    QPushButton
    
        
        Hello world!
        
    



hellotr,pro

SOURCES      = main.cpp
TRANSLATIONS = hellotr_la.ts

target.path = $$[QT_INSTALL_EXAMPLES]/linguist/hellotr
INSTALLS += target

QT += widgets

RESOURCES += hellotr_lang.qrc


Cheers
--
Nicholas Yue
Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
Custom Dev - C++ porting, OSX, Linux, Windows
http://au.linkedin.com/in/nicholasyue
https://vimeo.com/channels/naiadtools

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QVariant toBool() not working correctly?

2021-01-26 Thread Robert Hairgrove

On 26.01.21 17:37, Giuseppe D'Angelo via Interest wrote:


You've been bit (...)

LOL ... pun was intentional, I assume?
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QStringBuilder buffer overflow with string litteral?

2021-01-25 Thread Robert Hairgrove

+1 ... this has indeed bitten me more times than I like to admit!

Bob Hairgrove

--

On 25.01.21 15:27, Giuseppe D'Angelo via Interest wrote:

Hi,

Il 25/01/21 13:56, Olivier B. ha scritto:

         fields += (fields.isEmpty() ? "" : ", ") + '"' + field + '"';


QStringBuilder usage is a red herring, pay close attention at what 
you're doing in the first +: you're summing a const char * (result of 
the ternary operator) with a char; that does not do string 
concatenation...




___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QStringBuilder buffer overflow with string litteral?

2021-01-25 Thread Robert Hairgrove
Just an idea, not having to do with QStringBuilder ... why not do 
something like this?


QString fields = columns.join(", ");
if (fields.isEmpty()) fields = "*";
// ...

AFAIK it is only necessary to enclose field names in quotes if the name 
is an SQL keyword. If you still need to quote them, I would do it this way:


QString fields = columns.join("\",\"");
if (fields.isEmpty()) fields = "*";
else {
  fields.prepend("\"").append("\"");
}
// ...

HTH,
Bob Hairgrove

--

On 25.01.21 13:56, Olivier B. wrote:
Compiling with QT 5.11.1 & |QT_USE_QSTRINGBUILDER||, i get an error 
with the following code block:|


  QString generateQuery(const QString& tableName, const QStringList& 
columns, int count)

  {
    QString fields = "*";
    if (!columns.isEmpty())
    {
      fields.clear();
      for (const QString& field : columns)
      {
        fields += (fields.isEmpty() ? "" : ", ") + '"' + field + '"';
      }
    }
...

I just want to build a comma separated list of the items in 'columns', 
surrounded by quotes.
But instead of giving "A", "B", "C", this gives UNIQUE (%1)"A"UNIQUE 
(%1)"B"UNIQUE (%1)"C"


That UNIQUE (%1) is only found in another cpp file of the same DLL 
project, in strings ", UNIQUE (%1)" passed to QString constructors. So 
not only is it using the wrong string litteral, it does not read it 
from the string start.


Passing one/both of the operands of the ternary operator as QStrings 
makes the problem disappear.


Are there things i should be aware of when using QStringBuilder, such 
as 'do not put expressions on operators, because of macros that will 
evaluate them multiple times', or something like that?

String pooling (/GF of visual studio) is not used, if that matters

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Qt 6.0 removed Xml Patterns

2020-12-11 Thread Robert Hairgrove
I cannot seem to find any articles about QXmlPatterns which would 
explain WHY this very useful module was deprecated in 5.13 (or 5.15?), 
then removed in 6.0?


Is it a licensing issue?

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Qt 6.0 removed Xml Patterns

2020-12-09 Thread Robert Hairgrove
How do we validate an XML document against a schema file (.xsd) stored 
in Qt resources, for example, now that XML patterns has been removed?


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Translating JSON files

2019-06-18 Thread Robert Hairgrove

On 17.06.19 21:41, Mitch Curtis wrote:

Is there a way to translate data that's not stored in a C++ or QML file, like 
JSON? I have a bunch of user-facing strings in a JSON file that will eventually 
need to be translated, and there doesn't seem to be any solution for this.

Take a look at Translation Toolkit (it's an open source project, I 
believe written in Python):


http://docs.translatehouse.org/projects/translate-toolkit/en/latest/index.html

They have conversion tools for many popular formats and languages 
including JSON. Also, the Qt .ts file format seems to be supported 
(click on the link to the "Supported formats" page).


HTH,
Bob Hairgrove

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Built in DataBase for Qt 4.8.4

2013-04-25 Thread Robert Hairgrove
On Thu, 2013-04-25 at 12:12 -0400, Michael Jackson wrote:
 Is there any built in or In Memory database structures that are already 
 in Qt 4.8? I have a need for some light searching of our documentation and my 
 idea was to generate an in-memory database table that the built in QSQL 
 stuff could use to generate the results from?
 
 3rd Party libs maybe?

SQLite has in-memory databases ... and there has been an interface for
SQLite in QtSql for a long time, IIRC.

There is also the QSettings class which might provide all the
functionality you need.

What format do you use to store the documentation?

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Built in DataBase for Qt 4.8.4

2013-04-25 Thread Robert Hairgrove
On Thu, 2013-04-25 at 12:33 -0400, Michael Jackson wrote:
 On Apr 25, 2013, at 12:18 PM, Robert Hairgrove wrote:
 
  On Thu, 2013-04-25 at 12:12 -0400, Michael Jackson wrote:
  Is there any built in or In Memory database structures that are 
  already in Qt 4.8? I have a need for some light searching of our 
  documentation and my idea was to generate an in-memory database table 
  that the built in QSQL stuff could use to generate the results from?
  
  3rd Party libs maybe?
  
  SQLite has in-memory databases ... and there has been an interface for
  SQLite in QtSql for a long time, IIRC.
  
  There is also the QSettings class which might provide all the
  functionality you need.
  
  What format do you use to store the documentation?
  
 
 Just to be clear, is SQLite part of the normal Qt compile or do I need to 
 download SQLite and compile that? I am really new to this part of Qt so be 
 kind. ;-)

I have only used the source code build of Qt, but there is always some
slightly older version of SQLite included in the source.

If SQLite is available on your client platform as a shared library, you
might need to be careful with the Qt build options. For example, this is
almost always true on Mac platforms. On Windows and Linux, not
necessarily so.

 Currently we write the raw documentation in Markdown and have DOxygen convert 
 it to HTML that is included with the app. We have a single button that the 
 user clicks and then we use QDesktop to launch their web browser pointing to 
 the main documentation page.

Look at the QAssistant interface. This is very good at giving your
application the required help functionality if your docs are already in
HTML format.


___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest