Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLabel to bring middle of a QVLayout
Forum Updated to NodeBB v4.3 + New Features

QLabel to bring middle of a QVLayout

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 284 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Swati777999S Offline
    Swati777999S Offline
    Swati777999
    wrote on last edited by
    #1

    Hi All,

    I have a doubt regarding aligning QLabel Widget inside a QVBoxLayout.

    Layout_Example5.PNG

    The outer black box is of QVBoxLayout. I have achieved this layout but the text in QLabel is left aligned. I want to make the text of the QLabel center aligned as well as modify it in terms of the style sheet. How can I do that?

    “ In order to be irreplaceable, one must always be different” – Coco Chanel

    Swati777999S 1 Reply Last reply
    0
    • Swati777999S Swati777999

      @Swati777999

      Alignment part is solved
      myLayout->setAlignment(myWidget,Qt::AlignCenter);

      Now, have to deal with font size and font style.

      A Offline
      A Offline
      anil_arise
      wrote on last edited by anil_arise
      #3

      @Swati777999 Layout haven't font setting but Any kind of Widget can be set font in Qt. For example I have QLabel type Widget

      QFont customFont;
      customFont.setItalic(true);
      customFont.setBold(true);
      customFont.setFamily("Arial Black");
      customFont.setPointSize(20);
      QLabel *label = new QLabel("my Label");
      label->setFont(customFont);
      

      for details font
      Or use set Stylesheet of that widget

      1 Reply Last reply
      2
      • Swati777999S Swati777999

        Hi All,

        I have a doubt regarding aligning QLabel Widget inside a QVBoxLayout.

        Layout_Example5.PNG

        The outer black box is of QVBoxLayout. I have achieved this layout but the text in QLabel is left aligned. I want to make the text of the QLabel center aligned as well as modify it in terms of the style sheet. How can I do that?

        Swati777999S Offline
        Swati777999S Offline
        Swati777999
        wrote on last edited by
        #2

        @Swati777999

        Alignment part is solved
        myLayout->setAlignment(myWidget,Qt::AlignCenter);

        Now, have to deal with font size and font style.

        “ In order to be irreplaceable, one must always be different” – Coco Chanel

        A 1 Reply Last reply
        0
        • Swati777999S Swati777999

          @Swati777999

          Alignment part is solved
          myLayout->setAlignment(myWidget,Qt::AlignCenter);

          Now, have to deal with font size and font style.

          A Offline
          A Offline
          anil_arise
          wrote on last edited by anil_arise
          #3

          @Swati777999 Layout haven't font setting but Any kind of Widget can be set font in Qt. For example I have QLabel type Widget

          QFont customFont;
          customFont.setItalic(true);
          customFont.setBold(true);
          customFont.setFamily("Arial Black");
          customFont.setPointSize(20);
          QLabel *label = new QLabel("my Label");
          label->setFont(customFont);
          

          for details font
          Or use set Stylesheet of that widget

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved