I used setGeometry() to move and size some buttons and a list on a Window. The problem is that the buttons and list have a certain order and are overlapping strangely. I don't even want them to overlap and don't understand why they are overlapping in the first place.
As they are in the code below, the only thing I can click is BtnPlay. The other button isn't even changing on a mouse over. Depending on how I position them things become click-able.
There was a point where I had the widget created first, furthest to the right, and the widget created last at the origin. Everything worked, which leads me to believe that they are overlapping on an unseen plain, but I don't understand why or how to fix it. In addition, When I put a button near the list (the button was on the left side of the list), for some reason the list was no longer click able. Set geometry allows me to set the top left co-ordinates, the width, and height of the widget. I don't understand why they would interfere with each other.
int Gui_Init(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setStyle("plastique");
QWidget Window;
Window.resize(800, 600);
QTrackList = new QListObj(&Window);
RebuildButton BtnRB(&Window);
PlayButton BtnPlay(&Window);
Window.show();
return app.exec();
return 0;
}
RebuildButton::RebuildButton(QWidget *parent) : QWidget(parent)
{
Rebuild = new QPushButton(tr("Rebuild Library"), this);
Rebuild->setGeometry(400,575,100,25);
connect(Rebuild, SIGNAL(clicked()), this, SLOT(RebuildLibrary()));
}
PlayButton::PlayButton(QWidget *parent) : QWidget(parent)
{
PlayBtn = new QPushButton(tr("Play Track"), this);
PlayBtn->setGeometry(400, 550, 100, 25);
connect(PlayBtn, SIGNAL(clicked()), this, SLOT(PlayTrack()));
}
The Constructor for QListObj:
QListObj::QListObj(QWidget *parent) : QWidget(parent)
{
List = new QListWidget(parent);
List->setGeometry(500,0,300,600);
new QListWidgetItem(tr("fix it"), List);
connect(List, SIGNAL(itemSelectionChanged()), this, SLOT(SelectTrack()));
}