0

basically I have a QLabel* in the mainwindow. I tried to set it as the centralWidget. When the program is running, it is fine if the mainWindow stays the original size. However, if I enlarge the size, there suddenly comes a gap between the QLabel and the toolBar from no where!!!! How can I do to get rid of it!!!

The funny thing is, although there is gap being created, the x and y coordinate of the QLabel did not change!!!! How could this happen!!!!

........................................................................

I used QTCreator to make a ScrollArea as the centralWidget. This way, when I enlarge the QMainWindow, the ScrollArea enlarges automatically. However, the problem is. When I tried to call setWidget function to set the Label into the ScrollArea, the same problem above occured again!!!!

Someone, please help!!!!!!!!!!!!!

This is what I tried, but apparently does not work:

the code is:

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    imageLabel = new QLabel();
    image = new QPixmap(480,320);
    image->fill();
    imageLabel->setPixmap(*image);
    setCentralWidget(imageLabel);
}

enter image description here

Douglas B. Staple
  • 10,510
  • 8
  • 31
  • 58
user1819047
  • 667
  • 9
  • 18
  • Post code so we can see why your are getting this behavior. Chances are there is something wrong with the parent hierarchy or the layouting. – Thomas Mar 06 '13 at 15:10
  • It would help seeing the ui. There might be layouts in there or widgets that your label should be a child of. – Thomas Mar 06 '13 at 22:34

1 Answers1

0

To me it looks like a layout issue, you've set the size of the label already, once you resize your window it stays at the size already set unless you specifically set it's size again, or you're using one of the QLayout layout managers.

Nicholas Smith
  • 11,642
  • 6
  • 37
  • 55