문제

I'm trying to learn how to create the layout of my Qt Symbian application so that it will expand/shrink and fit into the screen size of different devices.

In my default ui I have added a QTabWidget with five tabs that I want to fit into the screen of the device. I have two problems:

  1. How can I make the tabs to shrink to always fit into the screen of the device, or is that not possible? What if one device has a width of 240px and another a width of 400px. As you can see now (Nokia Emulator) the tabs go outside of the screen. (And I don't want to use ScrollButtons)

  2. As you can see in the red part of the picture (Nokia Emulator ) there is some spacing in the UI that I don't want. Instead I want the QTabWidget to fill the whole screen (all the red part).

In summary I'm learning right now and it would be great if you could give me some tips about where to look for more info regarding these problems with building an UI that fits into many devices and screen resolutions. Thanks!

This is the code in my UI file:

void setupUi(QMainWindow *UITest)
{
    if (UITest->objectName().isEmpty())
        UITest->setObjectName(QString::fromUtf8("UITest"));
    UITest->resize(284, 167);
    QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    sizePolicy.setHorizontalStretch(0);
    sizePolicy.setVerticalStretch(0);
    sizePolicy.setHeightForWidth(UITest->sizePolicy().hasHeightForWidth());
    UITest->setSizePolicy(sizePolicy);
    centralwidget = new QWidget(UITest);
    centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    verticalLayout = new QVBoxLayout(centralwidget);
    verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
    tabWidget = new QTabWidget(centralwidget);
    tabWidget->setObjectName(QString::fromUtf8("tabWidget"));
    tabWidget->setTabPosition(QTabWidget::South);
    tabWidget->setUsesScrollButtons(false);
    tab = new QWidget();
    tab->setObjectName(QString::fromUtf8("tab"));
    tabWidget->addTab(tab, QString());
    ...More tabs...        

    verticalLayout->addWidget(tabWidget);

    UITest->setCentralWidget(centralwidget);

    retranslateUi(UITest);

    QMetaObject::connectSlotsByName(UITest);
} // setupUi

void retranslateUi(QMainWindow *UITest)
{
    UITest->setWindowTitle(QApplication::translate("UITest", "UITest", 0, QApplication::UnicodeUTF8));
    UITest->setStyleSheet(QApplication::translate("UITest", "background: red;\n" "padding: 0px;", 0, QApplication::UnicodeUTF8));
    tabWidget->setStyleSheet(QApplication::translate("UITest", "background: white;\n" "margin: 0px;\n" "padding: 0px;", 0, QApplication::UnicodeUTF8));
} // retranslateUi

In main.cpp showMaximized() is used to show my widget as I also want the menu buttons in the bottom.

도움이 되었습니까?

해결책

대신 write-output를 사용하고 파일로 리디렉션 할 수 있습니다 (> outptcsvfilename.csv 또는 pipe to out-file oppercsvfilename.csv)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top