You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

BoardTroll

Beginner

  • "BoardTroll" started this thread

Posts: 15

Location: Muncie, Indiana

Occupation: Software Engineer

  • Send private message

1

Tuesday, July 6th 2004, 3:49pm

Button trouble

I am having problems inserting a button to an HBox. I can add any control I want except for a button. At first I thought it wasn't showing up but I changed the background color to black and I get a black box to show up. The text from the button is missing too.

this produces a yellow box with no text:

Source code

1
2
3
4
5
QButton *b = new QButton(l);
b->setText("OK");
b->setFixedSize(50, 50);
b->setBackgroundColor(yellow);
l->addWidget(b);


this works correctly

Source code

1
2
QSlider *b = new QSlider(0, 10, 1, 0, Qt::Horizontal, l);
l->addWidget(b);


here's what addWidget() is

Source code

1
2
3
4
void ToolboxWidget::addWidget( QWidget *w )
{
    layout->insertWidget(-1, w);
}

rhg

Trainee

  • "rhg" is male

Posts: 178

Location: Velbert, Germany

Occupation: senior software developer

  • Send private message

2

Tuesday, July 6th 2004, 3:55pm

Did you ever read the QButton doc? ;)

It says:
"The QButton class is the abstract base class of button widgets, providing functionality common to buttons."

Conclusion: If you want a push button, use QPushButton. If you want a check box, use QCheckBox.

http://doc.trolltech.com/3.3/qbutton.html

BoardTroll

Beginner

  • "BoardTroll" started this thread

Posts: 15

Location: Muncie, Indiana

Occupation: Software Engineer

  • Send private message

3

Tuesday, July 6th 2004, 4:21pm

uhhhh, heh.

i r an software engineer.

I did read it a few times, trying to see what I missed. That is, I read it all except for the first sentance, hehe.

Thanks!