“You look at your stylesheet in awe, amazed at your own artistic power. You have just styled your widget to perfection, and it is so beautiful one could cry. Now, just to finish off with that one-pixel adjustment to the left, and…. what!? Why does it suddenly look different?”
I am sure many of you have been there when stylesheets do unexpected things. This stems from the fact that the styles were not originally meant to support stylesheets and all the adjustment capabilities that come with them. So whenever a stylesheet tries to do something that the underlying style cannot offer, it falls back onto a different style.
For this reason, we are currently aiming at trying to make stylesheets a little more consistent and predictable, and there are several approaches that can be followed. I hereby invite the readers to post some comments about what they think is important with stylesheets.
You are free to write whatever you feel, but here are some guiding questions:
- What is your typical use of stylesheets? Giving widgets a brand new look, or just changing a color here and there?
- Is your program used on more than one platform?
As a relatively new Trolltech employee (this is my first post!), I was thrown into Qt’s printing framework, with the hopes of improving some of the long standing issues.
One of the problems with printing using Qt today isn’t actually printing itself, but rather information about printers. The current framework is very opaque; typically a programmer just has to set a printer name on a QPrinter object, start painting and hope that it reaches some printer out there. The only way to reliably select a printer is by using QPrintDialog and let the user select it there. However, the programmer cannot influence the appearance or behavior of the dialog, nor can he/she automate the choice of printers.
With this in mind, we started working on a new class, QPrinterInfo, whose task is to provide information about the printers that are installed on the system. Some API decisions are yet to be made, but users will be able to query for installed printers, which printer is the default, and what paper sizes each printer supports.
Here is an example of how you can list the printers on a system:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDialog dialog;
QLayout* layout = new QGridLayout;
QPushButton* ok = new QPushButton(QLatin1String("OK"));
QLabel* text = new QLabel;
layout->addWidget(text);
layout->addWidget(ok);
dialog.setLayout(layout);
QList<QPrinterInfo> printerList = QPrinterInfo::availablePrinters();
QString printers("Printers:\n");
for (int c = 0; c < printerList.size(); ++c) {
printers += printerList[c].printerName();
printers += QLatin1String("\n");
}
printers += "\nDefault:\n";
printers += QPrinterInfo::defaultPrinter().printerName();
text->setText(printers);
QObject::connect(ok, SIGNAL(clicked()), &dialog, SLOT(accept()));
dialog.show();
dialog.exec();
return 0;
}
