July 31, 2011

justdad justdad
Lab Rat
20 posts

[solved] Multiple Lines of text in QToolbox buttons

 

I would like to create an “accordian” type of box for messages and it looks like a QToolbox would be perfect. When I have messages comming in the user, I plan on adding the brief message to the button and then the user can press on the tool box button to get the complete message as well as a “Action Button” for the job the user needs to do. So if no message are pending for the user to address, there are no buttons in the toolbox. If there is just one message, then just one button and so forth.

However, some of my “brief” messages may be several lines long. Is is possible to increase the height of the individual buttons to make them all, say 3 lines long, instead of the just one line long as the default?

ken

5 replies

July 31, 2011

Eddy Eddy
Area 51 Engineer
1612 posts

if you use a QPushButton like this, you should get what you want. I adapted the example from the QDialogButtonBox docs.

  1. findButton = new QPushButton(tr("Find\ntesting\ntesting"));  //watch the newline \n
  2.      findButton->setDefault(true);
  3.  
  4.      moreButton = new QPushButton(tr("&More;"));
  5.      moreButton->setCheckable(true);
  6.      moreButton->setAutoDefault(false);
  7.  
  8.      buttonBox = new QDialogButtonBox(Qt::Vertical);
  9.      buttonBox->addButton(findButton, QDialogButtonBox::ActionRole);
  10.      buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole);

 Signature 

Moderator
Qt Certified Specialist
Nokia Qt Ambassador

August 11, 2011

justdad justdad
Lab Rat
20 posts

OK, this works great.

How do I “dock” the Button box? Conceptually I would like to just have a this button box in the middle of a form with or without a small border like GroupBox.

August 11, 2011

Eddy Eddy
Area 51 Engineer
1612 posts

Can you explain a bit more wat you want? Did you use a layout?

 Signature 

Moderator
Qt Certified Specialist
Nokia Qt Ambassador

August 13, 2011

justdad justdad
Lab Rat
20 posts

Thanks! The layout hint is what I needed. I used a formlayout with two columns. I put a push button on the left with either a “>” or a “V” icon in it depending if the message box was expanded or not. Then when the push button was pressed the push button would toggle and the amount of data in the label would change. Since I was using a formlayout, the items below/above would automatically adjust and it works great. With rich text in the label, I get everything I wanted.

Thanks again.

August 14, 2011

Eddy Eddy
Area 51 Engineer
1612 posts

Great you solved it!

Could you edit your title and add [solved] in front of it?

[done -mariusg]

 Signature 

Moderator
Qt Certified Specialist
Nokia Qt Ambassador

 
  ‹‹ [Solved] How to skip fast keystroke in search?      [Solved] How to combine multiple QSqlQueryModel? ››

You must log in to post a reply. Not a member yet? Register here!