PDA

View Full Version : Font size of a spinbox



SailinShoes
4th May 2008, 16:33
I define the font size for all views/widgets in main. But I would like to set a different font size to a spinbox in one of the views. I do this explicitly like this



pSpinbox = new QSpinBox(this);
QFont font( pSpinbox->font() );
font.setPointSize( 48 );
pSpinbox->setFont( font );


But the font size of the spinbox remains the same? What is wrong?

wysota
4th May 2008, 18:22
Could we see a larger portion of the code? Especially the main().

SailinShoes
4th May 2008, 20:10
int main(int argc, char *argv[])
{
QApplication app(argc, argv);



return app.exec();
}

wysota
4th May 2008, 20:44
Not really helpful. What's between lines 3 and 7?

SailinShoes
5th May 2008, 07:36
int main(int argc, char *argv[])
{

QApplication app(argc, argv);

HmiMonitor *monitor = new HmiMonitor;

monitor->initiate();

return app.exec();

}

void HmiMonitor::initiate()
{

KeyboardHandler *pKeyboard = new KeyboardHandler;

QPalette pal;
pal.setColor(QPalette::Base, QColor(Qt::black));
pal.setColor(QPalette::Window, QColor(Qt::black));
pal.setColor(QPalette::Text, QColor(255, 230, 0));
QApplication::setPalette(pal);

QApplication::setFont(QFont("Helvetica", 16));

SignalSubscriber *pSignalSubscriber = new SignalSubscriber;

CommandManager *pCommandManager = new CommandManager;

ViewManager *pViewManager = new ViewManager(
pSignalSubscriber->getSignalManager(),
pCommandManager);

}

wysota
5th May 2008, 08:02
So assuming that you apply the font to the spinbox in the constructor, you first change spinbox's font and then set the default font for the application overriding your earlier changes. Try doing it the other way round (contents of initialize() can be moved into the constructor).

SailinShoes
5th May 2008, 15:29
I have tried your proposal, but it does not work. I should add that the code is executed on Qtopia in an embedded system. I suspect it has to do with Qtopia.

I have done some prototyping on my laptop and there are no problems to change font size.

I have talked to the company that provide the embedded target and Qtopia to check if there
are some limits of the font sizes?