I don't use the Qt Designer - all of this layout is done in code. While investigating with this problem, I changed my code so that creation and presentation are broke into 3 steps
1. create all widgets (called once)
2. place all widgets in layout (called once)
3. update widget contents, show/hide widgets based on data changes (called initially + as needed for changes)
Actually, I have done some more investigation this morning with a profiler and have discovered some interesting facts. The layout is slow, but it is the creation of the widgets which is really taking most of the time. For example, doing just the following in a parent widget ctor takes 577 milliseconds!
lbAddress
= new QLabel("Address");
lbCategory
= new QLabel("Category");
lbElements
= new QLabel("Elements");
lbScaling
= new QLabel("Scaling");
lbInfoName = new QLabel;
lbInfo = new QLabel;
lbTableName = new QLabel;
lbType = new QLabel("Type");
cbType = new QComboBox;
ckFlipX = new QCheckBox("Flip X");
ckFlipY = new QCheckBox("Flip Y");
ckSwapXY = new QCheckBox("Swap XY");
lbName = new QLabel("Name");
leName = new QLineEdit;
lbAddress = new QLabel("Address");
leAddress = new QLineEdit;
lbCategory = new QLabel("Category");
cbCategory = new QComboBox;
lbElements = new QLabel("Elements");
leElements = new QLineEdit;
cbScaling = new QComboBox;
lbScaling = new QLabel("Scaling");
pbScaling = new QPushButton("New Scaling...");
teStaticValues = new QTextEdit;
teDescription = new QTextEdit;
gbStaticValues = new QGroupBox;
gbDescription = new QGroupBox;
To copy to clipboard, switch view to plain text mode
There are 6 such parent widgets in my dialog, and along with about 1 second spent on layout and other Qt operations taking another second or more, the dialog takes closer to 6 seconds to display, which is an eternity. I looked more carefully at the time spent in Qt widget ctors, and there wasn't really one type of widget that was much slower than another. Most of the actual CPU cycles end up being spent in the function
QWidgetPrivate::create_sys
Which accounts for almost 3.5 seconds (!) of the time to show this dialog.
I have tried running Debug .vs. Release builds, Plastique .vs. standard styles, but nothing has an effect on the speed. My system is a XPSP2, 2.8GHz P4, 800MHz FSB, 1GB CL2 RAM, AGP8X nVidia GeForce4 MX440 running dual DVI displays. It seems like some core part of creating the widgets on the native OS is slow, perhaps in Windows itself. I just don't see things being slow anywhere else on my system, or even in other parts of my app (although I don't create so many widgets anywhere else).
Any ideas?
Bookmarks