qlabel centering

  • 1 Answer(s)

    The qlabel centering:

    The text in a QLabel by call the  QLabel::setAlignment  . The Layout  will be automatic resized the widget  in the Layout Management

    #include <QApplication>
    #include <QHBoxLayout>
    #include <QLabel>
    #include <QWidget>
    int main(int argc, char* argv[]) {
        QApplication app(argc, argv);
        QLabel* label=new QLabel("Hello World!");
        QWidget* widget=new QWidget;
        // create horizontal layout
        QHBoxLayout* layout=new QHBoxLayout;
        // and add label to it
        // set layout to widget
        return app.exec();
    Answered on January 11, 2019.
    Add Comment

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.