maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   I'm learning with Qt and I have a question (https://talk.maemo.org/showthread.php?t=47962)

Venemo 2010-04-20 10:39

Re: I'm learning with Qt and I have a question
 
Quote:

Originally Posted by mikhas (Post 618925)
http://doc.trolltech.com/4.6/qwidget.html#closeEvent

Reimplement this event handler to ignore the close event on a certain condition. Also see the example which explains why this can be useful.

Thanks!

I'll post the solution here, in case anyone else wants it. It bugs me though, that it can't be done without creating a derived class.

Code:

#ifndef UNCLOSEABLEMESSAGEBOX_H
#define UNCLOSEABLEMESSAGEBOX_H

#include <Qt>
#include <QtGui>
#include <QtCore>

class UncloseableMessageBox : public QMessageBox
{

public:

    UncloseableMessageBox(const QString& title, const QString& text, Icon icon, QWidget *parent = NULL) : QMessageBox(icon, title, text, QMessageBox::Ok, parent)
    {
        this->button(QMessageBox::Ok)->hide();
    }

    void closeEvent(QCloseEvent *event)
    {
        event->ignore();
    }

};

#endif // UNCLOSEABLEMESSAGEBOX_H

If anyone finds a mistake, I'd appreciate it if you tell me.

mikhas 2010-04-20 12:55

Re: I'm learning with Qt and I have a question
 
Quote:

Originally Posted by Venemo (Post 619089)
Thanks!

I'll post the solution here, in case anyone else wants it. It bugs me though, that it can't be done without creating a derived class.

That's just how Qt rolls: signals here, but events there. There is nothing a signal couldn't do what an event can do (from my POV).
However, if you have a crappy signal and slot implementation (slow, preprocessor-based, no real namespace support, no compile-time checks, no flexible parameter binding, only QSignalMapper or private slots) then you try everything to get around it, at least when performance and correctness is important. Well, and turns out that this actually *is* important if you write frameworks or libraries.

That's why you have this seemingly arbitrary separation between signals and events in Qt, even though it makes no sense to the application developer (which would almost always prepare a signal over an event, simply because it is easier to use and more flexible).

You'll soon get used to the Qt mantra of deriving custom classes for every little feature though (I am not saying that this is a good habit).

Venemo 2010-04-20 13:59

Re: I'm learning with Qt and I have a question
 
Mikhas, you seem to know much about Qt.

Could you please view this thread?
It would be great if you could say something about that issue. :)

mikhas 2010-04-21 07:37

Re: I'm learning with Qt and I have a question
 
I only had a brief look at the example, it probably crashes because something else is closing your QDialog before you get to handle the dialog's response. But just looking at the code is not as helpful as simply running it through the debugger. So if you turn the code snippet into a compiling testcase (which still reproduces the crash) then I can help you.

Venemo 2010-04-21 11:23

Re: I'm learning with Qt and I have a question
 
Quote:

Originally Posted by mikhas (Post 620559)
I only had a brief look at the example, it probably crashes because something else is closing your QDialog before you get to handle the dialog's response. But just looking at the code is not as helpful as simply running it through the debugger. So if you turn the code snippet into a compiling testcase (which still reproduces the crash) then I can help you.

The entire source of the application (with Qt creator project files and all) is there at another post.

sifo 2012-10-25 18:24

Re: I'm learning with Qt and I have a question
 
Hello :)
guys im very very new to qt and development stuff so you got to excuse me...
ok so i have maemo SDK, scratchbox, and qt SDk installed on my ubuntu lucid ( 10.04 )
i created in qt-creator a hello-world app and it's directory contains :
-/qml/hellowrld/main.qml
-/qmlapplicationviewer/
--qmlapplicationviewer.cpp
--qmlapplicationviewer.h
--qmlapplicationviewer.pri
-helloworld.desktop
-helloworld.pro.user
-main.cpp
-helloworld.png
-helloworld.pro
-helloworld.svg

what steps i should do to compile that source and result a binary that i could send it to my N900 and run it :)
would really appreciate a short step by step guide :)

./sifo

Copernicus 2012-10-25 18:53

Re: I'm learning with Qt and I have a question
 
Quote:

Originally Posted by sifo (Post 1285506)
what steps i should do to compile that source and result a binary that i could send it to my N900 and run it :)
would really appreciate a short step by step guide :)

I'm not so sure there's a perfectly short guide to doing it. :) I think the most important item is probably to get the Maemo Toolchain for your SDK, if you haven't already. You can do this by starting up the SDK Maintenance Tool, going to the Package Manager, and drilling down to Qt SDK -> Development Tools -> Maemo Toolchain.

(At least, this is how I'm doing it. I haven't updated my SDK in almost a year though, so things might have changed a bit.)

Once you've got the toolchain, you should be able to set up Maemo 5 as one of the targets for your project. (There's a "Projects" icon on the left side of my Qt Creator window that allows you to edit project targets.)

There's a scratchbox environment you can use to simulate a N900 for testing purposes, and a wizard to simplify installing apps onto a real N900. You can also just copy a binary on to your device and run it directly, if you prefer.

Probably the best resource for me is the Qt Maemo/Meego Support Page, which contains links to most of the Maemo-related documentation on their website.

So yeah, nothing extremely quick and easy to get you started, but once you've got all the bits and pieces in place, it's easy to build binaries and get them on to your device. :)

sixwheeledbeast 2012-10-25 19:23

Re: I'm learning with Qt and I have a question
 
Here's some pages I bookmarked in Firefox from when I setup my environment a couple of months ago.

http://wiki.maemo.org/Documentation/...-based_systems

http://wiki.maemo.org/Documentation/...own_the_SDK_UI

http://talk.maemo.org/showthread.php?t=68684&page=2

Qt "Build" will create files that are upload-able to extras.
This makes a source.changes, dsc and tar files for the autobuilder.

To create armel debs I move the files to scratchbox MyDocs directory and run in scratchbox armel targets...

Code:

dpkg-buildpackage -rfakeroot -sa
This makes a armel.deb, and armel sources.
I install the armel.deb to my N900 to test.

If the package works OK, I upload the file created by Qt "build" to autobuilder.

Remember if using this method to change your compat file to 5 as 7 will not work in scratchbox.

qwazix 2012-10-25 19:32

Re: I'm learning with Qt and I have a question
 
I usually prefer using madde, makes my life easier, and works as well.

Just install madde on N900, add maemo toolchain from the QtSDK update tool, go to options -> linux devices -> device configuration on QtCreator and let the wizard guide you.

sifo 2012-10-25 21:47

Re: I'm learning with Qt and I have a question
 
Thank you all for your replies
And here come the story :D how can i copy stuff from / to scratchbox (MyDocs) ?

./sifo

marxian 2012-10-25 21:57

Re: I'm learning with Qt and I have a question
 
Quote:

Originally Posted by sifo (Post 1285567)
Thank you all for your replies
And here come the story :D how can i copy stuff from / to scratchbox (MyDocs) ?

./sifo

Code:

cp <files> /scratchbox/users/<username>/home/<username>/MyDocs
You can also mount directories in scratchbox like this:

Code:

sudo mount --bind <directory> /scratchbox/users/<username>/home/<username>/MyDocs/mydir
The above example mounts the chosen directory in scratchbox as a subdirectory of MyDocs called 'mydir'.

I prefer to use the second approach when working with Qt Creator and scratchbox, as there is then no need to copy files. I write code in Qt Creator, then compile in scratchbox. :)

sifo 2012-10-25 22:05

Re: I'm learning with Qt and I have a question
 
Thank you marxian that helped a lot ( silly me )

sifo 2012-10-26 13:03

Re: I'm learning with Qt and I have a question
 
1 Attachment(s)
the qt-sdk version i have is 1.1.2 i downloaded this old as i expected to have maemo target ( which was not in 1.2.1 ) and i only have now the desktop and qt simulator targets !
so when i go to the SDKMaintenanceTool i get an error as in the screenshot !
please help

( im thinking about moving to learn python or Gtk+, do you recommend that ? )
Thanks

marxian 2012-10-26 13:32

Re: I'm learning with Qt and I have a question
 
1 Attachment(s)
You should be able to add the Maemo5 toolchain to the latest version of the SDK. No need to install an earlier version. However, as a (possible) fix, I have attached the files from my 'Licences' folder. Place these in your ~/QtSDK/Licences folder (create the folder if it does not already exist).

sifo 2012-10-26 13:51

Re: I'm learning with Qt and I have a question
 
that directory is already there, but i overwrite with your files and still the same error :(
but hold on ! im in a blocked country ! is this what causing the whole problem ?
Much appreciated

./sifo

marxian 2012-10-26 14:10

Re: I'm learning with Qt and I have a question
 
Quote:

Originally Posted by sifo (Post 1285882)
that directory is already there, but i overwrite with your files and still the same error :(
but hold on ! im in a blocked country ! is this what causing the whole problem ?
Much appreciated

./sifo

I don't think so. It's complaining that the file does not exist. Maybe it is looking in the wrong location. Do you have multiple versions of the SDK installed?

sifo 2012-10-26 14:13

Re: I'm learning with Qt and I have a question
 
No but i have multiple qt-creator versions, one from the SDK and one from ubuntu repos, im going now to remove what i dont need :)
Thanks

sifo 2012-10-26 14:26

Re: I'm learning with Qt and I have a question
 
still the same error :(
im thinking about reinstalling the sdk, but i cant find it in the "installed apps" in application manager, shuold i use rm -r ?
thanks

marxian 2012-10-26 15:03

Re: I'm learning with Qt and I have a question
 
Quote:

Originally Posted by sifo (Post 1285896)
still the same error :(
im thinking about reinstalling the sdk, but i cant find it in the "installed apps" in application manager, shuold i use rm -r ?
thanks

QtSDK is (by default) installed in ~/QtSDK. So you can remove it simply by deleting that folder.

sifo 2012-12-19 20:36

Re: I'm learning with Qt and I have a question
 
So i gave up making Tor working on my ubuntu ( i need it to access the sdk repo ),
Finally i got ride of it on my Windows 7 by using hot spot shield, Downloading now Maemo tool-chain, i hope it will work fine :)
thank you all

./sifo

Edit : i failed downloading it :mad: i got "data corrupted error" will try reinstalling the whole sdk as i played too much with it.

demolition 2012-12-19 23:10

Re: I'm learning with Qt and I have a question
 
Yeah, I'm having a little trouble with the Fremantle toolchain, too.

I've just installed Nokia Qt SDK 1.2 on Debian Wheezy and have one main thing preventing completion of the setup: I cannot get the Fremantle Toolchain to register with Qt Creator, despite downloading the entire SDK.

- How can the toolchain be recognised with Qt Creator, so software can be built for Fremantle, not just Harmattan?
- Do I need to install the Fremantle SDK as well?

Also, what's up with the version numbers? The Maintenance Tool claims it's creating a Fremantle toolchain for Qt 4.7.0, then the folder that's actually created is labelled 4.6.2 - doesn't the device running Qt 4.7.5?

Any ideas or assistance that might help resolve the problem described, would much appreciated.

qwazix 2012-12-19 23:29

Re: I'm learning with Qt and I have a question
 
I just installed the toolchain with the SDK maintenance tool and it worked. You may need to find qmake by hand on the toolchains tab if that didn't work.

I don't know what is it with the versions, I had this concern myself. N900 runs 4.6.3 IIRC on PR1.3 but CSSU provides 4.7.4

sixwheeledbeast 2012-12-20 09:23

Re: I'm learning with Qt and I have a question
 
Quote:

Originally Posted by demolition (Post 1306198)
- How can the toolchain be recognised with Qt Creator, so software can be built for Fremantle, not just Harmattan?

IIRC I manually added:-

Code:

/opt/QtSDK/Maemo/4.6.2/targets/fremantle-pr13/bin/qmake
In Options > Build & Run

demolition 2012-12-20 13:21

Re: I'm learning with Qt and I have a question
 
1 Attachment(s)
Thanks for the helpful comments.

Not sure what I've done wrong. Below is a screen shot of the Tools > Options > Build & Run menu.

Everything appears to be in order, looking through the directories. However, Qt Creator cannot detect qmake in the Maemo folder, even when trying to select it manually! Is there a command line instruction to associate it?

The toolchain is installed, apparently...
Code:

user@PC:~$ ls ~/QtSDK/Maemo/4.6.2/targets/fremantle-pr13/bin/
addr2line  cc      gcc    gprof    mgen  objcopy    qt.conf  size
ar        c++filt  gcov    ld        mmoc  objdump    ranlib  strings
as        cpp      gdb    lrelease  moc  qmake      rcc      strip
c++        g++      gdbtui  lupdate  nm    qmake-qt4  readelf  uic

Code:

user@PC:~$ cat ~/QtSDK/Maemo/4.6.2/targets/fremantle-pr13/information
sysroot fremantle-arm-sysroot-20.2010.36-2-slim
toolchain arm-2007q3-51sb6-gdb71-arm-none-linux-gnueabi_linux
runtime qemu-n900-pr13
qttools qt-tools-4.7.0-m0.20.32-linux

Code:

user@PC:~$ ls ~/QtSDK/Maemo/4.6.2/sysroots/ | grep fremantle
fremantle-arm-sysroot-20.2010.36-2-slim

user@PC:~$ ls ~/QtSDK/Maemo/4.6.2/toolchains/arm-2007q3-51sb6-gdb71-arm-none-linux-gnueabi_linux/
arm-none-linux-gnueabi  bin  include  lib  libexec  toolchain.files

user@PC:~$ ls ~/QtSDK/Maemo/4.6.2/runtimes/qemu-n900-pr13
information                    RX-51_2009SE_20.2010.36-2.nand
RX-51_2009SE_20.2010.36-2.emmc  skin

user@PC:~$ ls ~/QtSDK/Maemo/4.6.2/tools/qt-tools-4.7.0-m0.20.32-linux/
bin  lib

I probably need to do some grep-ing through to check that every entry in "~/QtSDK/Maemo/4.6.2/toolchains/arm-2007q3-51sb6-gdb71-arm-none-linux-gnueabi_linux/toolchain.files" is actually where it's supposed to be.
If anyone know's of a one-liner do assist I'd be very grateful - something with this, perhaps?
Code:

for item in `cat toolchain.files | awk '{print $2}'`; do ...
- to display the files that are listed but Not installed.

sixwheeledbeast 2012-12-20 17:38

Re: I'm learning with Qt and I have a question
 
1 Attachment(s)
Quote:

Originally Posted by demolition (Post 1306341)
Thanks for the helpful comments.

Not sure what I've done wrong. Below is a screen shot of the Tools > Options > Build & Run menu.

Everything appears to be in order, looking through the directories. However, Qt Creator cannot detect qmake in the Maemo folder, even when trying to select it manually! Is there a command line instruction to associate it?

I had trouble with the latest Ubuntu which is why I run everything Maemo Development related in a VM with Debian Squeeze and purposely update nothing in my VM.

Here's a screenshot of my Qt, I can't remember doing any really special apart from following the text based scratchbox installer wiki and adding the qmake location.

All of my stuff is installed in /opt not /home but that shouldn't matter.

qwazix 2012-12-20 17:58

Re: I'm learning with Qt and I have a question
 
Check if qmake is executable


All times are GMT. The time now is 22:33.

vBulletin® Version 3.8.8