PDA

View Full Version : Making my Application sole focus !



fassage
11th November 2009, 09:15
Hi All,

I have designed a dialog with a pixmap, some labels and a progress bar !

When i execute the code, it appears but unless i move the mouse inside the application and click the mouse inside it, the progressbar doesnt show its progressing ! I think this must be the focus of the window right ?

How can i achieve this automatically ??

Really need some help !

Thanks

wysota
11th November 2009, 09:23
Progress bar has nothing to do with focus. It has to be something else, please show us your code.

fassage
11th November 2009, 09:33
Hi Wysota,

You absolutely right !

Indeed it has nothing to do with the progressBar, but instead i am applying a Qpalette to change the highlight color of the progress bar !

Once i do this, when i run the application, it no longer shows the progressbar progressing !

Can you shed some light ?

Once i comment out my attempts to change the color, it works as expected !



//QPalette pal;
//QColorGroup cg;
//cg.setColor( QColorGroup::Foreground, white );
//cg.setColor( QColorGroup::Background, black );
//cg.setColor( QColorGroup::Highlight, white );
//cg.setColor( QColorGroup::HighlightedText, white );
//cg.setColor( QColorGroup::Text, white );
//pal.setActive( cg );

pb = new QProgressBar( this, "pb" );
pb->setGeometry( QRect( 10, 130, 370, 24 ) );
//pb->setPalette( pal );

fassage
11th November 2009, 10:13
After some tests i managed to find a working solution !

If i apply the palette to the dialog / widget, the progressBar will inherit these colors at its construction and display these correctly.

If however, you apply the palette directly on the progressBar after its construction, a mouse click inside the active window is required to display it as expected.

I am still uncertain why the mouse click inside the active window then initiates its display ??

However, this does pose a problem if one wanted to have two progress bars (or indeed any 2 widgets) with 2 seperate Palette's.

Looking forward to your feedback.

Regards

Fassage