Results 1 to 4 of 4

Thread: Align WindowTitle text to the Center in Windows 10

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Align WindowTitle text to the Center in Windows 10

    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
    Attached Images Attached Images

Similar Threads

  1. Align text and icon of QToolButton on center
    By bibhukalyana in forum Qt Programming
    Replies: 7
    Last Post: 24th November 2014, 12:46
  2. Qwt, Align content to center
    By Asting in forum Qwt
    Replies: 3
    Last Post: 18th June 2014, 11:06
  3. Replies: 3
    Last Post: 20th February 2014, 15:14
  4. Replies: 2
    Last Post: 23rd February 2010, 07:52
  5. How to align list items to the center?
    By zgulser in forum Qt Tools
    Replies: 4
    Last Post: 9th February 2009, 09:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.