PDA

View Full Version : Understanding Projects with ancient Qt Designer (3.1)



cooperman
24th September 2014, 11:30
Hi Guys,

First let me say that I've been programming for more years than I care to remember, however I'm brand new to Qt.
I’m having to support some old software that runs on HP-UX and was produced using Qt Designer 3.1 (Qt 3.1.2) (looks to be about 2003 vintage). (Please note that for various reasons, a decision has been made to stick with this version, so please don’t tell me to use the latest version).

I know I'll have lots of questions, but my first one is to do with the relationship between Projects and other components (specifically 'Main Window' and 'Dialog').

I sort of expected that I could create a Project with all of my GUI files within it, (like in Visual Studio). So what I did was…
New -> ‘C++ Project’
I called it Adhoc
Then I wanted to create the main window, so…
New -> ‘Main Window’
I called it ‘Adhoc Main’
When I close Qt Designer and reopen the ‘Adhoc’ project I expected that it would also open ‘Adhoc Main’, but no, it shows the Adhoc project in a little box on the toolbar, but the ‘Adhoc Main’ form doesn’t open.
There’s a menu option under ‘Project’ called ‘Add File’. I’ve tried adding ‘Adhoc Main’ to the project using this option, but the ‘Adhoc Main’ form still doesn’t get opened when I open the project.

Any ideas?

Many thanks

Gary

Added after 42 minutes:

OK, so I've got it listing my forms when I open the project, however I had to move the files around and manually edit Adhoc.pro to get it working...
Directory layout (new names)...
Adhoc/Adhoc.pro
Adhoc/frmAdhocMain.ui
Adhoc/frmAddAdhocItem.ui

Adhoc.pro contents…
unix {
UI_DIR = .ui
MOC_DIR = .moc
OBJECTS_DIR = .obj
}
FORMS = frmAdhocMain.ui \
frmAddAdhocItem.ui
TEMPLATE =app
CONFIG += qt warn_on release
LANGUAGE = C++

The question that I’ve got now is can I get Designer to open Adhoc.pro by default when it starts up?

Many thanks,

Gary

Added after 4 minutes:

Also, on the New/Open dialogue, the 'Recently Opened' tab now shows links to stuff that no longer exists (has been moved/renamed). Is there a file somewhere that I can edit to update the 'Recently Opened' list?

Thanks again,

Gary

anda_skoa
24th September 2014, 16:37
There seems to be a misunderstanding somewhere.

Qt Designer is an editor for .ui Files, a visual layouting tool. It is not an IDE.

If you are using QtCreator, you'll have to be careful not to edit the .ui files with the built-in designer, since that is of a newer version.

Cheers,
_

cooperman
25th September 2014, 08:14
Hi Anda,

I'm not using QtCreator at all. It's a very old version of Qt Designer (3.1), which I am indeed using for form design.

Any help with my 2 queries for Qt Designer (3.1) would be much appreciated.

Many thanks,

Gary

anda_skoa
25th September 2014, 10:48
Which IDE are you using then, if you are using one?

If you are using just an editor, then manually edit the .pro and run qmake when you've changed it.

Nothing really related to Designer, if it changes any of the .ui files, the Makefile generated by qmake will take care of applying the uic rules again on the next make invocation.

Cheers,
_

cooperman
25th September 2014, 11:32
Hi Anda,

At the moment, I'm not using an IDE. I'm developing the functional specification and using Qt Designer to 'mock-up' the various forms.
I've got Eclipse on my machine, so I don't know if I can use that when I get round to doing the coding.

BTW, I've tried running qmake and it says...
QMAKESPEC has not been set, so configuration cannot be deduced.
Error processing file .../Adhoc.pro
Any ideas?

Thanks,

Gary

Added after 8 minutes:

Incidentally, I got Qt Designer to open my project when it starts by starting it from a script and giving the project path as an argument...

#!/bin/sh
LD_LIBRARY_PATH=//home/coopega1/tools/Qt/qt-3.1.2/lib/i86_linux /home/coopega1/tools/Qt/qt-3.1.2/bin/i86_linux/designer /home/coopega1/Projects/AdhocTrend/QtFiles/Adhoc/Adhoc.pro

Best regards,

Gary

wysota
25th September 2014, 13:26
As far as I remember there is an "Open Project" entry in the Designer 3.1 menu somewhere which will open a pro file for you. Then you need to open particular .ui files if you need them and work from there. But in general don't expect any IDE-like support in Designer, it can only do syntax highlighting for you and will open ui.h files for you when you double click buttons you placed on forms. If you never had experience with Qt3 Designer, I suggest you don't use it but rather use QtCreator as IDE and only edit ui files in Designer (and pay attention not to open ui files with Creator). I'm also not sure if you will be able to build your projects from within Creator or will you have to use the command-line interface.

cooperman
25th September 2014, 13:34
Hi Wysota,

We have other apps in our disribution built with this version Qt Designer and Qt3 and for various reasons we're keen to stick with these development tools.
What benefits exactly would Qt Creator give me if I can't use it to edit my ui files and can't use it to build the application?
Is there a version of Qt Creator that I can download that will work with Qt3?

Many thanks,

Gary

wysota
25th September 2014, 15:05
Qt Creator offers automating the building process, offers code highlighting, code completion and other more or less sophisticated editing tools Qt3 Designer doesn't have. It is not something you can't live without, though.

cooperman
25th September 2014, 15:08
Is ther a version of Qt Creator that I can use for Qt/Qt Designer 3?

Many thanks,

Gary

anda_skoa
25th September 2014, 15:14
We have other apps in our disribution built with this version Qt Designer and Qt3 and for various reasons we're keen to stick with these development tools.

Wysota was not suggesting to change that :)



What benefits exactly would Qt Creator give me if I can't use it to edit my ui files and can't use it to build the application?

QtCreator is a really nice C++ IDE, with special "understanding" of Qt, e.g. completion in SIGNAL/SLOT connections.
But you can use Eclipse as well.



Is there a version of Qt Creator that I can download that will work with Qt3?

Any version of QtCreator should do, i.e. it does not need to be built with the same version of Qt that the projects are using.
You can configure toolchains, called "kits" in QtCreator, including which Qt version to use.

Cheers,
_

cooperman
25th September 2014, 15:43
Hi Anda,

I found the bit to add kits and it seemed to me like I needed to also create a new Qt Version (as only 4.8.5 was listed). Anyhow, I've added a new verion and pointed it to where my qmake executable is (/home/coopega1/tools/Qt/qt-3.1.2/bin/i86_linux), but it says:

Could not determine the path to the binaries of the Qt installation, maybe the qmake path is wrong?
Any ideas?

Many thanks,

Gary

wysota
25th September 2014, 16:05
Hi Anda,

I found the bit to add kits and it seemed to me like I needed to also create a new Qt Version (as only 4.8.5 was listed). Anyhow, I've added a new verion and pointed it to where my qmake executable is (/home/coopega1/tools/Qt/qt-3.1.2/bin/i86_linux), but it says:

Could not determine the path to the binaries of the Qt installation, maybe the qmake path is wrong?
Any ideas?

Many thanks,

Gary

Yeah, I think Qt Creator cannot work out of the box with qmake versions for Qt3 as the output it expects to receive is not generated by Qt3. However with little tweaking you should probably be able to make it work. That's not what you should be focussing on right now, though, as you can perform the build process manually just like you did until now.

cooperman
25th September 2014, 16:16
Hi Wysota,

Really appreciate your help (and Anda's).

Yeah, the reason that I started looking at that was because I'd been going through a video tutorial on the web and it has been talking about signals and slots and I was trying to make a button on my Main Window, open another form (Dialogue) that I'd created. Unfortunately, the only form listed was frmMain and not any of my sub-forms. Anyhow, I thought that if I could make Qt Creator a 'wrapper' around the work I'd done so far, then I might be able to make my other forms 'receivers'.

BTW, any clues about the tweaking that you mention?

Cheers,

Gary

wysota
25th September 2014, 18:40
Yeah, the reason that I started looking at that was because I'd been going through a video tutorial on the web and it has been talking about signals and slots and I was trying to make a button on my Main Window, open another form (Dialogue) that I'd created. Unfortunately, the only form listed was frmMain and not any of my sub-forms. Anyhow, I thought that if I could make Qt Creator a 'wrapper' around the work I'd done so far, then I might be able to make my other forms 'receivers'.
Creator is just an advanced code editor, it will not turn your non-working solutions into working solutions.


BTW, any clues about the tweaking that you mention?

You'd have to provide a script or some other qmake stand-in to provide output Creator expects to receive when querying your qmake. You have to trick Creator to think it deals with Qt4 qmake.

anda_skoa
26th September 2014, 08:52
Yeah, the reason that I started looking at that was because I'd been going through a video tutorial on the web and it has been talking about signals and slots and I was trying to make a button on my Main Window, open another form (Dialogue) that I'd created. Unfortunately, the only form listed was frmMain and not any of my sub-forms.

Ah.
In this case you don't need designer at all for the moment.

For each form UIC will have generate a class.
What you do additionally is having another class each that inherits from the generated on.

In the class that inherits from your main window form class, you add a slot and connect that to the button.
In the slot you create an instance of the class inheriting from the second form class and show it.

Alternatively you can create the instance of the second class earlier and connect the button's clicked() signal to the second window's show() slot.

Cheers,
_

wysota
26th September 2014, 09:38
For each form UIC will have generate a class.
What you do additionally is having another class each that inherits from the generated on.
As far as I remember in Qt3 "by default" the class generated is used directly and not inherited. The Designer lets one edit a xxx.ui.h file which gets included by uic generated code. So if OP maintains some code written earlier, it is likely ui.h is already used and inheriting without refactoring existing code.

anda_skoa
26th September 2014, 12:31
As far as I remember in Qt3 "by default" the class generated is used directly and not inherited. The Designer lets one edit a xxx.ui.h file which gets included by uic generated code. So if OP maintains some code written earlier, it is likely ui.h is already used and inheriting without refactoring existing code.

That was possible but really not recommended.

The difference between Qt4 and Qt4 in this context is that Qt4's UIC does not generate a QWidget derived class, so there are now additional options other than inheritance, e.g. the ui pointer member.

Cheers,
_

wysota
26th September 2014, 17:07
That was possible but really not recommended.
I know but it was the default behaviour of Qt Designer. So it is likely that legacy code makes use of this approach.

anda_skoa
26th September 2014, 18:05
I know but it was the default behaviour of Qt Designer.

I don't think Designer ever created additional files by default.
When you create a form, it only saves that into a single .ui file.



So it is likely that legacy code makes use of this approach.
Maybe. In 14 years of developing Qt application in various contexts I've never come across any non-trivial project using that approach due to it being way to limited for a sustainable development workflow.

Inexperienced people with tiny pet projects maybe, but anyone else I've encountered preferred a programmer's editor or IDE for writing C++ code.

Cheers,
_