Hi
Is there any alternative or style sheet for QMainWindow or QDialog for Title Bar Text Alignment. I have one Alternative method for Align Text to the Center of MainWindow. Sample Code is below....
void MainWindow::resizeEvent(QResizeEvent *event)
{
QString strTitle("My Application");
QString strGap = QString(" ");
QFont font("Arial",11);
QFontMetrics fontM(font);
int nWid = fontM.width(strTitle);
int nWidSpace = fontM.width(strGap);
int nLengthPixmap = 10;
double STPoint = (double)((double)(this->width()/2-nLengthPixmap) - (double)nWid/2);
double widthOfSpace = (double)nWidSpace;
QString strG = QString(" ");
double tmpWidth = 0;
for(;(tmpWidth+widthOfSpace < STPoint)
{
strG += QString(" ");
tmpWidth += widthOfSpace;
}
QString strFinal = strG + strTitle;// + strG;
setWindowTitle(strFinal);
}
I have customize resizeEvent, it will set the title bar to the center. But problem is that, Due to Center Alignment text taskbar only show Application Icon followed by ....., I have attached the ScreenShot of My Application, Due to Center Alignment, Text shift also from TaskBar..
Can you please give the solution that What is missing by me, After Center alignment of Window Title Text, Bottom Task Bar should also show Application's window title as in screenshot of other program..
Thanks
Santosh Kumar Singh
Bookmarks