OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> My first application: Done. A few questions
jdf
post Mar 13 2004, 06:45 PM
Post #1





Group: Members
Posts: 33
Joined: 28-February 04
Member No.: 2,078



I am new to Qt and C++ and only progran as a hobby. I got my Z one month ago. I just finished my first application thankx to some help from members of this board.

The app is just a Unit Conversion Program. Wrote it as a training exercise, not because anyone needed another conversion program! In any case I attached the source code to this message. (don't expect it to be pretty). I tested the file and it will compile and run under dev-x86-qpe environment, dev-arm-qpe and transferred to Z works fine; also under winXP envronment works fine. The program uses customizable text files as the conversion database. I included these data files in the attachment too. They should be in the same directory where you run the program from.

Here are my questions:

1) What is the best way to get the application to start full screen. What screen size should be used? My app seems to start a little bit less than full size and then I can maximize it.

2) I use a QLabel and a QLineedit. How can I set the color for those backgrounds?

3) The Lineedit accepts keyboard entry from the Sharp hardware. I tried to do a connect of the textChanged signal to a Slot in mysoftware but this never works. Maybe some one could look at that connect statement.

4) I used a setCaption, but the title doesn't appear in the title bar?

Sorry if some of these questions may be obvious, but I have spent hours searching and trying to resolve them.

I placed the files here too:
http://www.delferro.net/zaurus

Thankx'JDF
Go to the top of the page
 
+Quote Post
lpotter
post Mar 13 2004, 09:37 PM
Post #2





Group: Members
Posts: 451
Joined: 27-November 03
From: Brisbane, Australia
Member No.: 1,001



JDF,
It's best to use dynamic layouts, that way your applications can resize itself according to the screensize, so it will work on 5500's, and c760's, and even screens that are 176x220 (like on a phone). I find gridlayouts are the easiest to code by hand..
You should use QPEApplication, instead of QApplication if you want to use Qtopia/Opie:

1)
#include <qpe/qpeapplication.h>

QApplication jdfapp( argc, argv );
j_uconvert jmain;
jdfapp.showMainWidget( &jmain );

2) Why do you want to color those? It's probably best not too, for the sake of gui uniformity.
3)
textChanged is called every keystroke, so you might want to use something else, like returnPressed, and then get the text of the QLineEdit
with in your slot
QString lineEditString = j_le_basevalue->text();
Go to the top of the page
 
+Quote Post
jdf
post Mar 14 2004, 08:57 AM
Post #3





Group: Members
Posts: 33
Joined: 28-February 04
Member No.: 2,078



lpotter,
Thankyou for helping me out. Here is some additional info
0. screen size:
I think I am using an QVbox for the layout. But it still seems not to start out MAXIMIZED, I also tried a grid layout in place of the QHBox and that also didn't start out MAXIMIZED. It starts a little smaller than screen and then I can tap the MAXIMIZE button on title bar and it maximizes to the screen. How can I start out maximized to the device?

1) I made the changes you pointed out
#include <qpe/qpeapplication.h>
QApplication jdfapp( argc, argv );
j_uconvert jmain;
jdfapp.showMainWidget( &jmain );
But then I get a problem with the later statements in main as I had them, including
jmain->show();
error: (base operand of `->' has non-pointer type `j_uconvert'
SO, I left everything as I originally had it But I did add my missing
#include <qpe/qpeapplication.h>
and deleted #include <qapplication.h>
NET RESULT: seems to perform same as original as far as the screen size problem.

2) Why do you want to color those?
Well the Linedit comes up the default WHITE which is OK. I want the LABEL below it to be White and kind of similar to the lineedit. The label comes up the same as the background screen. I would like it to be White or red say. I guess I could use a Linedit instead and make it noneditable.

3) textChanged is called every keystroke,

That's exactly what I want for this application, For each keystroke made I want to read the current value of the box. I thought my signal slot was configured right, but it never makes it to the slot.

4) SetCaption still doesn't appear even though changed to
#include <qpe/qpeapplication.h>

Again, I really appreciate your feedback. It has been difficult learning cpp, oop, QT, but this forum is great!!

JDF
Go to the top of the page
 
+Quote Post
markb
post Mar 14 2004, 04:23 PM
Post #4





Group: Members
Posts: 54
Joined: 28-February 04
From: Birmingham, UK
Member No.: 2,080



Hi jdf,

I haven't had a chance to look at your latest code yet.
But I can help out with one thing I spotted from your last post:

QUOTE
j_uconvert jmain;
jdfapp.showMainWidget( &jmain );
But then I get a problem with the later statements in main as I had them, including
jmain->show();
error: (base operand of `->' has non-pointer type `j_uconvert'


That looks like a slight pointer problem.
If you have an object, you call a method on it using ".".
But If you have a pointer to an object, you call a method using "->".

e.g.

CODE
MyClass anObj;

anObj.callMethod( arg1, arg2 );



MyClass *objPtr = new MyClass();

objPtr->callMethod( arg1, arg2 );


So, when you had a problem with
CODE
jmain->show()

it's because jmain isn't a pointer to an object, so you should do this instead:
CODE
jmain.show()


You've probably spotted that yourself by now.
But I thought I'd mention it anyway.

- Mark
Go to the top of the page
 
+Quote Post
BlackCardinal
post Mar 14 2004, 05:22 PM
Post #5





Group: Members
Posts: 70
Joined: 9-March 04
From: Albany, Oregon USA
Member No.: 2,232



I'm going to jump in here... in lpotter's post there is a typo. The code for the application object should actually be:

#include <qpe/qpeapplication.h>

QPEApplication jdfapp( argc, argv );
j_uconvert jmain;
jdfapp.showMainWidget( &jmain );

The typo was still declaring jdfapp to be a QApplication instead of a QPEApplication. I think if you use QPEApplication the window will automatically run maximized, and this will solve your mysterious pointer error, too.

Black Cardinal
Go to the top of the page
 
+Quote Post
BlackCardinal
post Mar 14 2004, 05:40 PM
Post #6





Group: Members
Posts: 70
Joined: 9-March 04
From: Albany, Oregon USA
Member No.: 2,232



OK, this time I actually downloaded your code and built it. Changing to QPEApplication does fix the screen maximizing problem.

setCaption() isn't working because it's not being called on the parent widget (j_uconvert), but instead on a QVBox contained within the parent widget. Change the call to simply:

setCaption("UCzz");

The connect call isn't working for two reasons:

1) It should be a call to the static QObject::connect function, which needs to be made explicitly, and
2) There are some extra pipe symbols in the line.

Here is how this statement should be made:

QObject::connect( j_le_basevalue, SIGNAL(textChanged(const QString&)), this, SLOT(sl_RealKYBD(const QString&)) );

Nice little program, by the way! Looks like you're having fun! biggrin.gif
Go to the top of the page
 
+Quote Post
jdf
post Mar 14 2004, 08:59 PM
Post #7





Group: Members
Posts: 33
Joined: 28-February 04
Member No.: 2,078



OK Blackbird.....
Seems like you zeroed right in on it!! Thankx!

I made only the changes you suggested in your post.
-Caption is correct
-Keyboard works great now
-Not sure about the full screen yet, but I think it will work.

In my qvbf it seems like it wasn't full screen and I could move the window around. Also when I ran it from terminal on Z5500 it didn't go full screen either and I could move the window around, but caption and keyboard were fine on the Z.

Let me try some other things and verify, before I ask it again!

I thought maybe if i packaged it onto the Z it would work, so I made an ipk, but have been unsuccessful at getting the Z to recognize the ipk for install. The only other ipk I made was for the "example" program and I did that OK, so I thought I did this one exactly the same.

If someone could look at the IPK, i'd appreciate it! :wink:

I put the ipk and current source here:
http://www.delferro.net/zaurus

Thankx everyone. Oh, markb, thankx for the insight into the pointer to an object and the actual object stuff. It helped me understand some other things!!

JDF
Go to the top of the page
 
+Quote Post
BlackCardinal
post Mar 15 2004, 12:48 PM
Post #8





Group: Members
Posts: 70
Joined: 9-March 04
From: Albany, Oregon USA
Member No.: 2,232



The data.tar.gz file in the IPK includes a zero-length file "Packages" that it's trying to install to /, which is a read-only directory if you install to memory. Remove that file and it will install fine.
Go to the top of the page
 
+Quote Post
jdf
post Mar 15 2004, 08:13 PM
Post #9





Group: Members
Posts: 33
Joined: 28-February 04
Member No.: 2,078



I apologize for my last post referencing "Blackbird" :!:
BlackCardinal: Thankx again. I am getting the hang of this now!

OK: The program is basically working the way I wanted thanks to your suggestins. I have an ipk that successfully installs itself with icon, help file, and the data files into home/zaurus. It then executes from its icon in the Applications TAB. Does its stuff and exits cleanly. I am pretty happy.

My last issue is the screen layout. I have code in the ( j_uconvrt.cpp ) constructor to make a Gridlayout with a 5 row 2 column box. The first row is the file, the second row is the category, on the third row I have the Lineedit and the baseunit combo box side by side in col 1 and col 2. and 4th row has the output text and the converted unit combo box side by side.

In any case the layout doesn't seem to be applied. No errors, but i just get a single column VBox layout.

If anyone wants to try out the ipk or look at the code it can be downloaded here http://www.delferro.net/zaurus
Go to the top of the page
 
+Quote Post
BlackCardinal
post Mar 16 2004, 12:44 PM
Post #10





Group: Members
Posts: 70
Joined: 9-March 04
From: Albany, Oregon USA
Member No.: 2,232



QUOTE
I apologize for my last post referencing "Blackbird"

Hey, no problem! tongue.gif

I think it's because the main window is derived from QVBox, instead of QWidget. Try deriving your class j_uconvert from QWidget, and create a master layout that's a QVBoxLayout. Then insert your grid layout into this master layout.

Or, if your grid layout is the top level layout, you can insert it directly into j_uconvert, without needing the QVBoxLayout.

Kind of like this:

CODE
class j_uconvert : public QWidget

CODE
j_uconvert::j_uconvert(...) : QWidget(...)

{

    QVBoxLayout *master = new QVBoxLayout(this);



    QGridLayout *grid = new QGridLayout(this);

    master->addLayout(grid);



    QSomeWidget *otherWidget = new QSomeWidget(this, ...);



    grid->addWidget(...);

    grid->addWidget(...);



    master->addWidget(otherWidget);



    master->activate();

}


or:

CODE
j_uconvert::j_uconvert(...) : QWidget(...)

{

    QGridLayout *grid = new QGridLayout(this);



    grid->addWidget(...);

    grid->addWidget(...);



    grid->activate();

}
Go to the top of the page
 
+Quote Post
jdf
post Mar 16 2004, 07:16 PM
Post #11





Group: Members
Posts: 33
Joined: 28-February 04
Member No.: 2,078



Blackbird, thankx again....maybe I'll call this program ucbb !

I have the gridlayout working. Ran into a few glitches trying to set min row height and columns to control the layout Qt uses newer methods that didn't work on QPE

current Qt method is setRowSpacing
for QPE use legacy methods: addRowSpacing

It basically installs and looks great; however, the screen will expand larger than the screen size and start hiding widgets. This happens when the Lineedit gets a very large number in it! Before the gridlayout, this didn't happen. hmmmmmm. I'll try a few different ways of implementing the widgets and see if that changes anything. right now I just implement it in the main widget. Maybe if I implement it inside the QVBox. I'll experiment!

I put both the ipk and the current files at http://www.delferro.net/zaurus

In any case, I have progressed to where I feel comfortable and can take a break and CLEAN THE HOUSE AND GARAGE AND RUN ALL THOSE PROMISED ERRANDS before my wife gets back from her vacation!! That's the only reason I got to play with this thing for the last 3 weeks!

I'll get back to this next week. I really appreciate all the help directly from blackbird and markb, as well as all the other informative posts all over this board!

jdf
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 25th July 2014 - 03:04 PM