Sunday, July 6th 2008, 4:57pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Sauli

Beginner

1

Tuesday, April 1st 2008, 1:17pm

qt designer generated .h file requires a small modification to get the imageviewer layout work

I tried to clone the functionality of the imageviewer example at http://doc.trolltech.com/4.3/widgets-imageviewer.html by implementing the user interface with qt designer 4.4.0-beta1 to a Main Window.

In order to get the functionality right I had to comment one line in the .h file that was generated by qmake from the .ui file. Without the modification the layout setting and resizing of the scrollArea widget seemed strange.

I don't like modifying machine generated code and I would like to know is there a better way to circumvent the problem I faced.

The line commented in the .h file is
// SaulinQTDesignedUiWindow->setCentralWidget(centralwidget);

I added the following line to my imageviewer.cpp file
setCentralWidget(scrollArea);

For the convenience of the reader I inserted the original imageviewer example files as comments to files main.cpp, imageviewer.cpp and imageviewer.h. The MainWindow file produced by qt designer is imview.ui. Notice that I have commented one line in the ui_imview.h file, don't overwrite it by mistake with qmake.

Sauli
Sauli has attached the following files:
  • main.cpp (837 Byte - 13 times downloaded - Last download: May 24th 2008, 3:57am)
  • imageviewer.cpp (11.51 kB - 29 times downloaded - Last download: Jun 19th 2008, 3:49pm)
  • imageviewer.h (2.97 kB - 13 times downloaded - Last download: Jun 25th 2008, 2:09am)
  • imview.ui (5.14 kB - 14 times downloaded - Last download: Jun 25th 2008, 8:26am)
  • ui_imview.h (8.72 kB - 15 times downloaded - Last download: May 24th 2008, 3:58am)
  • Go to the top of the page

Rate this thread