PDA

View Full Version : unable to popup the QSlider on top of the pushButton



qwakaw
16th July 2008, 10:27
hi ,

I am able to popup a slider on the click of a button, but it's not on top of the button...
what should I do ..

here is the code


class MainWindow : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
MainWindow( QWidget * parent = 0, Qt::WFlags f = 0 );


QFrame *popup1;

private slots:

void pushButton_clicked();
};

MainWindow::MainWindow( QWidget * parent, Qt::WFlags f)
: QMainWindow(parent, f)
{
setupUi(this);

connect(pushButton, SIGNAL(clicked()), this, SLOT(pushButton_clicked()));

popup1 = new QFrame( this, Qt::Popup);
popup1->resize(40,100);

QSlider *slid = new QSlider(Qt::Vertical, popup1);
slid->resize(40,100);
slid->show();
}

void MainWindow:pushButton_clicked()
{
popup1->move(mapToGlobal(pushButton->geometry().bottomLeft()));

popup1->show();

}

marcel
16th July 2008, 10:30
You must add a simple layout to the frame, such as vertical or horizontal.
Next, add the slider to the layout.
It should work.