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


All times are GMT. The time now is 18:17.

vBulletin® Version 3.8.8