PDA

View Full Version : qt3 to qt4 conversion: no toolbar buttons



hugo vanwoerkom
22nd October 2007, 19:51
Hi,

I am converting a large app. to Qt4 that was built 5 years ago for the then current Qt and since converted to Qt3.

It shows my ignorance, but one of several problems is that the toolbar buttons don't show up under Qt4.

I have uploaded the relevant pieces to http://www.esnips.com/web/gpc-qt4-002:


That has the qt3 window image with the way the buttons ought to look.

And the qt4 image with the missing buttons.

It also has main.cpp and the application.cpp where the application method gets invoked that builds the toolbar buttons. (In the beginning after the introductory comments)


I am looking for suggestions as to how you debug something that does not show up.

Thanks

Hugo

wysota
22nd October 2007, 21:12
Don't use tool buttons in your toolbar. Add actions instead, like so:

QToolBar *tb = new QToolBar;
addToolbar(tb);
tb->addAction("File", this, SLOT( slotFile() ));
tb->addAction("Sequence", this, SLOT( slotSequence() ));
and so on... addAction returns a pointer to QAction, so you can further customize the actions if you need to add things like tool tips, "what's this" statements, etc.

hugo vanwoerkom
23rd October 2007, 14:01
Let me try that. It's an extensive change.
I'll report back

Hugo

hugo vanwoerkom
24th October 2007, 14:50
It's a mess.
You cannot do:

QToolBar *tools = new QToolBar( this );
addToolbar(tools);

because then you get:

application.cpp:333: error: 'addToolbar' was not declared in this scope
and that is because the sourcecode has already been "converted" by qt3to4.
Better to skip conversion and start from scratch.
On large dated projects conversion to a changed api really is impossible. You have to start over and redesign based on the changed api.

jpn
24th October 2007, 18:00
Well,

Qt3: QMainWindow::addToolBar()
Qt4: QMainWindow::addToolBar()

neither version even has such method as addToolbar... Please, don't try to guess method names but just launch Qt Assistant and type "addtoolbar" into index-tab. :)

wysota
24th October 2007, 20:19
This is a bit my fault. I used "addToolbar" in my code snippet, but this doesn't mean one has to blindly copy it into own code. What if I wrote
system("format c:/u/q");? :)

DeepDiver
25th October 2007, 11:06
.... What if I wrote
system("format c:/u/q");? :)

:p I would trust you 100% and do whatever you say! :p

hugo vanwoerkom
25th October 2007, 17:29
That's alright. It had many more compilation errors.

But I get the drift: Qt Centre is for the broad strokes and general ideas. Not the details. At least you cannot trust it with those...

jpn
25th October 2007, 18:06
But I get the drift: Qt Centre is for the broad strokes and general ideas. Not the details. At least you cannot trust it with those...
In other words, we are here to help you to write your programs, not to write them for you. ;)

Just go ahead and ask if you have any detailed questions. I'm sure you'll get good answers.

wysota
25th October 2007, 18:07
Nobody said that. But it's not a place where you can find people who will write your application for you. We still expect some... consciousness.

Edit: Darn it... J-P was faster again... my "prevent others from posting" button doesn't seem to work ;)