Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4066078
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:05:28+00:00 2026-05-20T16:05:28+00:00

I’ve got some QDialog subclasses that were designed on Windows and which are now

  • 0

I’ve got some QDialog subclasses that were designed on Windows and which are now being ported over to Mac OS X. The problem is that the default font on Mac OS X appears to be much bigger, so the dialogs look quite cramped.

What’s the best way of making the dialogs bigger on Mac OS X than on Windows? (The size must remain fixed on each platform and they must look native.)

An example is the dialogs in Perforce’s P4V.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:05:29+00:00Added an answer on May 20, 2026 at 4:05 pm

    I had the same problem when porting from Win32 to Mac OS X, especially with:

    a) Buttons: Their height (in pixels) has to be different in order to look the same.

    b) Labels: The font-size (in points) has to be different in order to look the same.

    I tried to create an -as possible- generic solution, following these rules:

    1. I performed all form and widget layout editing ONLY in one environment (Windows XP) and transfered the source to other (OS X) only for compilation & test.

    2. I created a generic OS-Dependend function to modify Button Height and Label’s font-size at runtime (see bellow) and I called this function from every custom dialog constructor, after setupUI() like this:

      someDialog::someDialog(QWidget *parent) : QDialog(parent)
      {
      setupUi(this);
      genAdjustWidgetAppearanceToOS(this);
      // …
      }

    3. I introduced an exception list in genAdjustWidgetAppearanceToOS(this) function,
      and put in it the names of all controls that I will not want to affect (nothing is perfect).

    Here it’s my generic function to check and see if it can be of any help to you:
    (!remember to modify at least the “DoNotAffect” list and append your labels/buttons names)

    // ======================================================
    // Adjust specific Widget children according to O/S
    // => Set Buttons height
    // => Set labels font size
    // ======================================================
    void genAdjustWidgetAppearanceToOS(QWidget *rootWidget)
    {
        if (rootWidget == NULL)
            return;
    
        QObject *child = NULL;
        QObjectList Containers;
        QObject *container  = NULL;
        QStringList DoNotAffect;
    
        // Make an exception list (Objects not to be affected)
        DoNotAffect.append("aboutTitleLabel");     // about Dialog
        DoNotAffect.append("aboutVersionLabel");   // about Dialog
        DoNotAffect.append("aboutCopyrightLabel"); // about Dialog
        DoNotAffect.append("aboutUrlLabel");       // about Dialog
        DoNotAffect.append("aboutLicenseLabel");   // about Dialog
    
        // Set sizes according to OS:
    #ifdef Q_OS_MAC
        int ButtonHeight = 32;
        int LabelsFontSize = 12;
    #else // Win XP/7
        int ButtonHeight = 22;
        int LabelsFontSize = 8;
    #endif
    
        // Append root to containers
        Containers.append(rootWidget);
        while (!Containers.isEmpty())
        {
            container = Containers.takeFirst();
            if (container != NULL)
            {
                for (int ChIdx=0; ChIdx < container->children().size(); ChIdx++)
                {
                    child = container->children()[ChIdx];
                    if (!child->isWidgetType() || DoNotAffect.contains(child->objectName()))
                        continue;
                    // Append containers to Stack for recursion
                    if (child->children().size() > 0)
                        Containers.append(child);
                    else
                    {
                        // Cast child object to button and label
                        // (if the object is not of the correct type, it will be NULL)
                        QPushButton *button = qobject_cast<QPushButton *>(child);
                        QLabel *label = qobject_cast<QLabel *>(child);
                        if (button != NULL)
                        {
                            button->setMinimumHeight(ButtonHeight); // Win
                            button->setMaximumHeight(ButtonHeight); // Win
                            button->setSizePolicy(QSizePolicy::Fixed,
                                                  button->sizePolicy().horizontalPolicy());
                        }
                        else if (label != NULL)
                        {
                            QFont aFont = label->font();
                            aFont.setPointSize(LabelsFontSize);
                            label->setFont(aFont);
                        }
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
i got an object with contents of html markup in it, for example: string
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a JSP page retrieving data and when single or double quotes are
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.