Neil DSouza | 1 Nov 2010 03:30
Picon

Re: Button embedded in a table - extracting table row data and passing to callback function when clicked

Dmitriy Igrishin <dmitigr <at> ...> writes:

> 
> 
> Hey Neil,One solution is to use WSignalMapper class.Another solution is to
make some methods which providesinformation about selected rows and call them
from the slotconnected to you WPushButton clicked signal. 

Hi Dmitriy,

      Thanks for the quick response - I saw the reply yesterday and wanted to
post the example below last night - but internet connection kept dropping every
few 30 secs  for some reason.

   Here is the "hello" example that works based on what you suggested.

Kind Regards,
Neil

#include <Wt/WApplication>
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WText>
#include <Wt/WString>
#include <Wt/WSignalMapper>

using namespace Wt;

(Continue reading)

OvermindDL1 | 1 Nov 2010 04:19
Picon

Re: Accented characters

On Sun, Oct 31, 2010 at 5:21 PM, John Robson <john.robson <at> usp.br> wrote:
> I'm doing my first page by changing the example Hello.
>
> When I use accented characters (á,à,ã,é,ê,ü,ç), page compiles fine but
> does not appear in the browser and in the terminal I get this error:
> "invalid numeric character entity"
>
> What can I do to write texts in Portuguese (which has accents)?

You are putting your non-ascii characters in an xml file and importing
it, and not in your source code, right?

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
witty-interest mailing list
witty-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest
Sohail Somani | 1 Nov 2010 06:01
Gravatar

Upgrading to Wt 3.1.6 and mapClass

Hi,

As suggested in the "Memory leaks" thread, I have been attempting to 
upgrade to Wt Dbo 3.1.6.

I've come across a problem however. My code does something like this:

myapp::createTables(); // hand-written sql via execute
session->mapClass<T>("T"); // Wt's map type to table T, created above

The problem seems to be that I cannot map classes after executing the 
SQL as I get the message:

   Cannot map tables after schema was initialized.

Fine, so I change the code to:

session->mapClass<T>("T"); // Wt's map type to table T, created later
myapp::createTables(); // hand-written sql via execute

Now the problem seems to be that Wt is actually doing a createTables() 
in the mapClass call as I now get the message:

   table T already exists

So I'm stuck. What is the correct method of writing your own sql to 
create tables?

Thanks

(Continue reading)

Dmitriy Igrishin | 1 Nov 2010 09:02
Picon

Re: Button embedded in a table - extracting table row data and passing to callback function when clicked

Hey Wim,

2010/11/1 Wim Dumon <wim-fsvWVe5cvas@public.gmane.org>
I'd propose to use boost::bind:
for(int i = 0; i < numRecords; ++i) {
 // Build your table here, including the buttons:
 WPushButton *b = new WPushButton("Show Record", this);
 b->clicked().connect(boost::bind(&MyClass::showRecordDetails, this, i));
}


void MyClass::showRecordDetails(int recordnumber)
{
 // Update other form with information from 'recordnumber'
 ...;
}

In many cases, boost::bind() is a nice alternative to WSignalMapper.

Yep, thanks! Agree.


--
// Dmitriy.


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
witty-interest mailing list
witty-interest@...
https://lists.sourceforge.net/lists/listinfo/witty-interest
Wim Dumon | 1 Nov 2010 09:33
Picon
Favicon

Re: Button embedded in a table - extracting table row data and passing to callback function when clicked

Neil,

Looks good, but you'll have less trouble with memory leaks if you use
a WString instead of a pointer to a WString in the example.

Wim.

2010/11/1 Neil DSouza <neil.xavier.dsouza@...>:
> Dmitriy Igrishin <dmitigr <at> ...> writes:
>
>>
>>
>> Hey Neil,One solution is to use WSignalMapper class.Another solution is to
> make some methods which providesinformation about selected rows and call them
> from the slotconnected to you WPushButton clicked signal.
>
> Hi Dmitriy,
>
>      Thanks for the quick response - I saw the reply yesterday and wanted to
> post the example below last night - but internet connection kept dropping every
> few 30 secs  for some reason.
>
>   Here is the "hello" example that works based on what you suggested.
>
> Kind Regards,
> Neil
>
>
>
> #include <Wt/WApplication>
> #include <Wt/WBreak>
> #include <Wt/WContainerWidget>
> #include <Wt/WLineEdit>
> #include <Wt/WPushButton>
> #include <Wt/WText>
> #include <Wt/WString>
> #include <Wt/WSignalMapper>
>
> using namespace Wt;
>
> class HelloApplication : public WApplication
> {
> public:
>  HelloApplication(const WEnvironment& env);
>
> private:
>  WLineEdit *nameEdit_;
>  WText *greeting_;
>
>  void greetWithData(Wt::WString * data);
> };
>
> HelloApplication::HelloApplication(const WEnvironment& env)
>  : WApplication(env)
> {
>  setTitle("Hello world");                               // application title
>
>  root()->addWidget(new WText("Your name, please ? "));  // show some text
>  nameEdit_ = new WLineEdit(root());                     // allow text input
>  nameEdit_->setFocus();                                 // give focus
>
>  WPushButton *b = new WPushButton("Greet me.", root()); // create a button
>  b->setMargin(5, Left);                                 // add 5 pixels margin
>
>  root()->addWidget(new WBreak());                       // insert a line break
>
>  greeting_ = new WText(root());                         // empty text
>
>        Wt::WSignalMapper<Wt::WString*> *myMap = new Wt::WSignalMapper<Wt::WString
> *>(this);
>        myMap->mapped().connect(this, &HelloApplication::greetWithData);
>        myMap->mapConnect(b->clicked(), new WString(" 1 2 3 4 = some sample data"));
>
> }
>
> void HelloApplication::greetWithData(Wt::WString * data)
> {
>          greeting_->setText("Hello there, " + nameEdit_->text() +
>                          " here is the data: " + *data);
> }
>
> WApplication *createApplication(const WEnvironment& env)
> {
>  return new HelloApplication(env);
> }
>
> int main(int argc, char **argv)
> {
>  return WRun(argc, argv, &createApplication);
> }
>
>
>
>
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> witty-interest mailing list
> witty-interest@...
> https://lists.sourceforge.net/lists/listinfo/witty-interest
>

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
Wim Dumon | 1 Nov 2010 09:53
Picon
Favicon

Re: Accented characters

That's a simple question with an insanely complicated answer.

A few guidelines:
1. I advise against putting non-ASCII characters in source code. The
behavior is compiler-dependent. In Wt, use an external XML file to
store those strings, and use
WApplication::messageResourceBundle().use("..."); to load them. In
your code, construct your internationalized WString using keys and tr:
new WPushButton(tr("ok"), this);. Added benefit is that your
application will be internationalized.
2. If you really want to write special characters in your source files
(knowing that it is a bad idea), you have a few options:
 // Usually works, as long as you save your .cpp file in the right
encoding for your platform: construct a WString from a wstring
WString(L"á,à,ã,é,ê,ü,ç");
 // Usually works on Linux, not on Windows. Assumes that your compiler
and input file use UTF-8 encoding
WString(fromUTF8("á,à,ã,é,ê,ü,ç"));
 // Interpret the string in the character encoding of the locale of
the environment in which your application runs. If you run a
portuguese Windows, your app will work, but if you install it on an
english Windows, your app will no longer work. It helps to specify a
locale explicitly between the quotes.
WString("á,à,ã,é,ê,ü,ç", std::locale(""));
// Will not work for non-ASCII characters: the string is interpreted
in the global C+ locale (by default the "C" locale, which only works
fine for ASCII characters):
WString("á,à,ã,é,ê,ü,ç");
// Unless you modify your global locale first (again, depends on how
your OS's environment was configured!):
// std::locale(): a copy of the global locale
// std::locale(""): construct a locale from the environment's LANG and
LC_* variables
// We set the global locale to a locale that is a copy of the current
global locale,
// but where the 'collate' and 'ctype' facets are copied from the
environment's locale.
// These facets contain the character
encoding/conversion/comparison/... aspects.
std::locale::global(std::locale(std::locale(), std::locale(""),
std::locale::collate | std::locale::ctype));

Bottom line: if constructing a WString from a std::string (or char *),
you have to tell Wt how that string was encoded. The default in C++,
the "C" locale, is generally not useful for anything but ASCII
characters.

I recently wrote a whole encoding-related story as answer to a bug report:
http://redmine.webtoolkit.eu/issues/555

BR,
Wim.

2010/11/1 John Robson <john.robson@...>:
> I'm doing my first page by changing the example Hello.
>
> When I use accented characters (á,à,ã,é,ê,ü,ç), page compiles fine but
> does not appear in the browser and in the terminal I get this error:
> "invalid numeric character entity"
>
> What can I do to write texts in Portuguese (which has accents)?
>
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> witty-interest mailing list
> witty-interest@...
> https://lists.sourceforge.net/lists/listinfo/witty-interest
>

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
Neil DSouza | 1 Nov 2010 10:59
Picon

Re: Button embedded in a table - extracting table row data and passing to callback function when clicked


Wim Dumon <wim <at> ...> writes:

> 
> Neil,
> 
> Looks good, but you'll have less trouble with memory leaks if you use
> a WString instead of a pointer to a WString in the example.
> 
> Wim.
> 

Thanks Wim,

    I will also try out the way you suggested earlier (using boost::bind) and
post  the example. Thanks very much for your help

Regards,
Neil

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
Magnus Arntzen | 1 Nov 2010 11:18
Picon
Picon

Re: Filling a WAbstractItemModel is time consuming

Thanks Dmitriy,

I didnt think of that :)
Works like a peach!

On 29.10.2010 19:03, Dmitriy Igrishin wrote:
> Of course, I mean a static object of WAbstactItemModel.
> 
> 2010/10/29 Dmitriy Igrishin <dmitigr@... <mailto:dmitigr@...>>
> 
>     Hey Magnus,
> 
>     How about a global object of WAbstractItemModel ?
> 
>     2010/10/29 Magnus Arntzen <magnus.arntzen@...
>     <mailto:magnus.arntzen@...>>
> 
>         Hi.
> 
>         Filling a WAbstractItemModel can be time consuming.
>         I currently read a tsv file into a WAbstractItemModel, however the
>         tsv-file is quite large and it takes some time to fill the model.
> 
>         Every time the page is reloaded the file is read over again,
>         causing an
>         annoying delay in the browser. Is it possible for the
>         web-application to
>         read this file and populate the model only once on startup? And
>         then all
>         sessions access the same model without reloading it? How?
> 
>         The model is not editable.
> 
>         Thanks for any input on this!
> 
>         Best regards,
>         M.Arntzen
> 
> 
>         ------------------------------------------------------------------------------
>         Nokia and AT&T present the 2010 Calling All Innovators-North
>         America contest
>         Create new apps & games for the Nokia N8 for consumers in  U.S.
>         and Canada
>         $10 million total in prizes - $4M cash, 500 devices, nearly $6M
>         in marketing
>         Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to
>         Ovi Store
>         http://p.sf.net/sfu/nokia-dev2dev
>         _______________________________________________
>         witty-interest mailing list
>         witty-interest@...
>         <mailto:witty-interest@...>
>         https://lists.sourceforge.net/lists/listinfo/witty-interest
> 
> 
> 
> 
>     -- 
>     // Dmitriy.
> 
> 
> 
> 
> 
> -- 
> // Dmitriy.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
> http://p.sf.net/sfu/nokia-dev2dev
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> witty-interest mailing list
> witty-interest@...
> https://lists.sourceforge.net/lists/listinfo/witty-interest

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
John Robson | 1 Nov 2010 12:50
Picon
Picon
Favicon

Re: Accented characters

Tks OvermindDL1 and Wim.

Im putting non-ascii characters in source code; but now I will study  
about using XML.

(It would be nice to work naturally with non-ascii characters in source code.)

If don't work I tell.

John

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
Tobias Wahl | 1 Nov 2010 15:07
Picon
Favicon

integrate an individual HTML <head>

Hi!

Is there any way to modify the wt-generated header of the html source-code?

To integrate a wt-based site into a content-management-system I have to modify the generated source code.

Regards,
Tobias
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
witty-interest mailing list
witty-interest@...
https://lists.sourceforge.net/lists/listinfo/witty-interest

Gmane