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. QBarSet; SetLabelColor & SetLabelFont don't work. Qt failure?

QBarSet; SetLabelColor & SetLabelFont don't work. Qt failure?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 948 Views 2 Watching
  • 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.
  • J Offline
    J Offline
    Josz
    wrote on last edited by Josz
    #1

    Hello community, (I Use Qt 5.11.2 on Windows with msvc15)

    I would like to adjust the Font style and the size in aQBarSet.
    From the beginning the simplest settings don't work

    I tried the next code:

    set2 = new QBarSet("MyText", this);
     QFont myDesiredText = QString("my_Desired_Text");
     myDesiredText.setPointSize(2);
     myDesiredText.setBold(1);
     set2->setLabel("MySecondText");            //work
     set2->setLabelColor(Qt::red);              //don't work
     set2->setLabelFont(myDesiredText);         //don't work
    

    The Label shoes at the end "MySecond text".

    I think that's an issue in Qt or perhaps I did't make the things fine.
    Please, could somebody show me how to configure the font type and its size in a QBarset?
    (I googled, but not successfully)

    thanks in advance.

    K 1 Reply Last reply
    0
    • J Josz

      Hello community, (I Use Qt 5.11.2 on Windows with msvc15)

      I would like to adjust the Font style and the size in aQBarSet.
      From the beginning the simplest settings don't work

      I tried the next code:

      set2 = new QBarSet("MyText", this);
       QFont myDesiredText = QString("my_Desired_Text");
       myDesiredText.setPointSize(2);
       myDesiredText.setBold(1);
       set2->setLabel("MySecondText");            //work
       set2->setLabelColor(Qt::red);              //don't work
       set2->setLabelFont(myDesiredText);         //don't work
      

      The Label shoes at the end "MySecond text".

      I think that's an issue in Qt or perhaps I did't make the things fine.
      Please, could somebody show me how to configure the font type and its size in a QBarset?
      (I googled, but not successfully)

      thanks in advance.

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @Josz

      Try to change the sequence and use use larger point size for a start e.g.:

      set2 = new QBarSet("MyText", this);
       QFont myDesiredText = QString("my_Desired_Text");
       myDesiredText.setPointSize(12);
       myDesiredText.setBold(true);
       set2->setLabelColor(Qt::red);       
       set2->setLabelFont(myDesiredText);
       set2->setLabel("MySecondText"); 
      

      Vote the answer(s) that helped you to solve your issue(s)

      J 1 Reply Last reply
      0
      • K koahnig

        @Josz

        Try to change the sequence and use use larger point size for a start e.g.:

        set2 = new QBarSet("MyText", this);
         QFont myDesiredText = QString("my_Desired_Text");
         myDesiredText.setPointSize(12);
         myDesiredText.setBold(true);
         set2->setLabelColor(Qt::red);       
         set2->setLabelFont(myDesiredText);
         set2->setLabel("MySecondText"); 
        
        J Offline
        J Offline
        Josz
        wrote on last edited by
        #3

        @koahnig Thank you very much

        Sadly didn't work.

        I tried:

          set2 = new QBarSet("MyText", this);
          QFont myDesiredText = QString("my_Desired_Text");
          myDesiredText.setPointSize(12);
          myDesiredText.setBold(true);
          set2->setLabelColor(Qt::red);
          set2->setLabelFont(myDesiredText);
        

        and the label shows "MyText" of the first line :-(

        K raven-worxR 2 Replies Last reply
        0
        • J Josz

          @koahnig Thank you very much

          Sadly didn't work.

          I tried:

            set2 = new QBarSet("MyText", this);
            QFont myDesiredText = QString("my_Desired_Text");
            myDesiredText.setPointSize(12);
            myDesiredText.setBold(true);
            set2->setLabelColor(Qt::red);
            set2->setLabelFont(myDesiredText);
          

          and the label shows "MyText" of the first line :-(

          K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @Josz
          I guess that you need at least the statement

          set2->setLabel("MySecondText"); 
          

          at the end.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • J Josz

            @koahnig Thank you very much

            Sadly didn't work.

            I tried:

              set2 = new QBarSet("MyText", this);
              QFont myDesiredText = QString("my_Desired_Text");
              myDesiredText.setPointSize(12);
              myDesiredText.setBold(true);
              set2->setLabelColor(Qt::red);
              set2->setLabelFont(myDesiredText);
            

            and the label shows "MyText" of the first line :-(

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by raven-worx
            #5

            @Josz said in QBarSet; SetLabelColor & SetLabelFont don't work. Qt failure?:

            QFont myDesiredText = QString("my_Desired_Text");

            what do you expect that this line does?
            Is there a font named my_Desired_Text?!

            Also you may want to try setLabelBrush(Qt::red)

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            J 1 Reply Last reply
            0
            • raven-worxR raven-worx

              @Josz said in QBarSet; SetLabelColor & SetLabelFont don't work. Qt failure?:

              QFont myDesiredText = QString("my_Desired_Text");

              what do you expect that this line does?
              Is there a font named my_Desired_Text?!

              Also you may want to try setLabelBrush(Qt::red)

              J Offline
              J Offline
              Josz
              wrote on last edited by
              #6

              @raven-worx Thanks raven

              I tried

                set2 = new QBarSet("MyText", this);
                QFont *font = new QFont("Helvetica",13,13,true);
                //font->setPixelSize(2);
                set2->setLabelFont(*font);
                set2->setLabelBrush(Qt::red);
                set2->setLabel("MySecondText");
              

              don't works either :-(

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Josz
                wrote on last edited by
                #7

                I found a solution. Not the expected, for this reason I will not mark it as solved, but works

                    QString thresholdText = "Threshold " + QString::number(threshold);
                    set2->setLabel("<b><font size=4 face = 'Nina'>"+thresholdText+"</font></b>");
                
                1 Reply Last reply
                0

                • Login

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