[Interest] Usable Qt [Was: download a file form http]

Sivan Greenberg sivan at omniqueue.com
Thu Jul 5 17:03:36 CEST 2012

On Thu, Jul 5, 2012 at 5:08 PM, Jason H <scorp1us at yahoo.com> wrote:
> The problem was an advanced user told you about the #include moc hack.
The example actually uses it, nobody told me about it :)

> It is not needed, or encouraged and is used by advanced developers to
> provide a SINGLE file example. In standard fashion, you'd have multiple
> files. I've only used the hack a few times myself, and you'd probably have
> realized it after a while of working with Qt.
I realize now that indeed everything is really involved and my
expectation of Qt to be as easy as dynamic language like Python are

Now, I'm trying to drop in this example to be used in my GUI app but
the build process in creator just breaks, although I've changed it to
.h file to make it easier for creator not to be confused not finding
an .h file:

L/home/sivan/QtSDK/Simulator/Qt/gcc/lib -lQtDeclarative -lQtGui
-lQtNetwork -lQtCore -lpthread
moc_filedownload.o: In function `DownloadManager::saveFileName(QUrl const&)':
make: Leaving directory `/home/sivan/QtSDK/client01'
moc_filedownload.cpp:(.text+0xf0): multiple definition of
`DownloadManager::saveFileName(QUrl const&)'
main.o:main.cpp:(.text+0x80): first defined here
moc_filedownload.o: In function `DownloadManager::saveToDisk(QString
const&, QIODevice*)':
moc_filedownload.cpp:(.text+0x320): multiple definition of
`DownloadManager::saveToDisk(QString const&, QIODevice*)'
main.o:main.cpp:(.text+0x2b0): first defined here
moc_filedownload.o: In function `DownloadManager::DownloadManager()':
moc_filedownload.cpp:(.text+0x4e0): multiple definition of
main.o:main.cpp:(.text+0x470): first defined here
moc_filedownload.o: In function
moc_filedownload.cpp:(.text+0x580): multiple definition of
main.o:main.cpp:(.text+0x510): first defined here
moc_filedownload.o: In function `DownloadManager::doDownload(QUrl const&)':
moc_filedownload.cpp:(.text+0x830): multiple definition of
`DownloadManager::doDownload(QUrl const&)'
main.o:main.cpp:(.text+0x7c0): first defined here
moc_filedownload.o: In function `DownloadManager::execute()':
moc_filedownload.cpp:(.text+0x880): multiple definition of
main.o:main.cpp:(.text+0x810): first defined here
moc_filedownload.o: In function `DownloadManager::DownloadManager()':
moc_filedownload.cpp:(.text+0x4e0): multiple definition of
main.o:main.cpp:(.text+0x470): first defined here
collect2: ld returned 1 exit status
make: *** [client01] Error 1
18:01:56: The process "/usr/bin/make" exited with code 2.
Error while building project client01 (target: Qt Simulator)
When executing build step 'Make'

Your help greatly appreciated!


> ________________________________
> From: Sivan Greenberg <sivan at omniqueue.com>
> To: Tony Rietwyk <tony at rightsoft.com.au>
> Cc: interest at qt-project.org
> Sent: Thursday, July 5, 2012 5:32 AM
> Subject: [Interest] Usable Qt [Was: download a file form http]
> Thanks Tony. With your help, is there a way to download a file using
> Qt, remain dependent only on Qt, and support multiple targets without
> having to create your own custom build scripts, reading qmake's code,
> finding alternative build system, reading QNAM's code (which I
> actually did) , spawning a python subprocess to do the actual
> downloading, and so forth?
> I'd  really just like to concentrate on my application logic and have
> a demo that downloads one file from a web service[0] real quick e.g.
> "rapid prototyping and POC". Perhaps this way of using Qt is not in
> par with the framework's nature and design; read: one has to become a
> Qt expert for a few years before achieving such a task?
> Or perhaps, and this is very valid argument, Qt is for those who
> really know what they are doing, and given my questions- I certainly
> do not, so should I revert to use Python/GTK which is my original
> expertise?
> Now, I am genuinely asking to create discussion and try to improve -
> If this is usable by others, I'd love us to think up a class for
> "humane" interface and be interested in contributing it (e.g. more
> high level operations like WebDAV/REST web or similar to)  to network
> operations which are now days pivotal in importance given cloud
> technology takes over.
> If Qt is not suitable for rapid prototyping, then I apologize for the
> noise, but I think if Qt is to survive forward we must follow suite
> with the rest of the industry and make network operations as easy[1]
> as creating a widget, IMHO. In general we need to make the common
> stuff easy, and the complex possible[2].
> That is if we claim to provide a "Generic application development
> framework that enables you to code once, deploy everywhere". There is
> no issue in being a niche technology with limited focus, but we must
> communicate this loudly and strongly so people making business
> decision upon our code will know exactly what they are "paying" or be
> able to pay only for what they eat[3].
> Also note, that drilling Google does not come with useful snippets to
> use, but then you could argue someone has to know how to use Google as
> well...
> If my tone sounds a bit harsh, or inappropriate I do apologize as
> everybody around here knows how much I absolutely love this project,
> its people and community and defend it furiously  myself against Nay
> Sayers that approached me with this exact issue and argument. But I do
> believe, that if we are to survive to next years of computing this
> kind of discussions and re-steering of the bowl by "new blood" in the
> community is crucial for the future.
> Thanks for you attention, and sorry for the long email!
> -Sivan
> ----
> [0]: https://gitorious.org/cquick#more
> [1]: Downloading a file in python:
> 'import urllib
> urllib.urlretrieve ("http://www.example.com/songs/mp3.mp3", "mp3.mp3")'
> [2]: http://en.wikipedia.org/wiki/Perl_6#History
> "In Perl 6, we decided it would be better to fix the language than fix
> the user" -Larry Wall. (reading the whole "History" paragraph would
> bring more insight so is a *very* recommended read).
> [3]:
> http://docs.pylonsproject.org/projects/pyramid/en/1.0-branch/narr/introduction.html
> "Pyramid takes a “pay only for what you eat” approach. This means that
> you can get results even if you have only a partial understanding of
> Pyramid."
> In that sense, I do not want to have to be HTTP and network expert to
> be able to download a file.
> On Thu, Jul 5, 2012 at 11:41 AM, Tony Rietwyk <tony at rightsoft.com.au> wrote:
>>> Sent: Thursday, 5 July 2012 6:03 PM
>>> Thanks for all of the replies, how do I then make the MOC step happen
>>> before everything else in Qt creator or by plainly using qmake?
>>> (letting qmake "do the right thing" did not work).
>>> Thanks again!
>>> -Sivan
>> It depends on your tool-chain, and how you created the build scripts.
>> I use hand-edited .pro (and .pri) files, and run qmake to generate Visual
>> Studio  and Xcode project files.
>> There is an option for qmake to create a .pro file, but I've never used
>> it.
>> Tony.
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
> --
> -Sivan
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest


More information about the Interest mailing list