Hi
I'va a simple window (QMainWindow):
{
this->setMaximumHeight(400);
QSqlQuery query
("SELECT Imie, Nazwisko, Data_operacji, Nazwa_operacji FROM m_transporty_operacje AS Top LEFT JOIN m_uzytkownicy AS U ON (U.ID_u=Top.ID_uzytkownik) WHERE ID_transport="+ID_transport
+" ORDER BY Data_operacji DESC");
int i = 0;
while (query.next()) {
GbTMP->setMinimumHeight(70);
GbTMP->setMaximumHeight(70);
QDateTime DTData
= query.
value(2).
toDateTime();
QLabel *Uzytkownik
= new QLabel(query.
value(0).
toString()+" "+query.
value(1).
toString());
QLabel *Data_operacji
= new QLabel(DTData.
toString("yyyy-MM-dd HH:mm:ss"));
GbTMP->setLayout(layoutTMP);
layout->addWidget(GbTMP,i++,0,1,1);
}
base->show();
this->setCentralWidget(base);
this
->move
(((QApplication::desktop()->width
()-this
->width
())/2),
((QApplication::desktop()->height
()-this
->height
())/2));
}
FormTransportOperacje::FormTransportOperacje(QString ID_transport, QWidget *parent) : QMainWindow(parent)
{
this->setMaximumHeight(400);
QWidget *base = new QWidget();
QGridLayout *layout = new QGridLayout(base);
QSqlQuery query("SELECT Imie, Nazwisko, Data_operacji, Nazwa_operacji FROM m_transporty_operacje AS Top LEFT JOIN m_uzytkownicy AS U ON (U.ID_u=Top.ID_uzytkownik) WHERE ID_transport="+ID_transport+" ORDER BY Data_operacji DESC");
int i = 0;
while (query.next()) {
QGroupBox *GbTMP= new QGroupBox(query.value(3).toString());
GbTMP->setMinimumHeight(70);
GbTMP->setMaximumHeight(70);
QGridLayout *layoutTMP = new QGridLayout();
QDateTime DTData = query.value(2).toDateTime();
QLabel *Uzytkownik = new QLabel(query.value(0).toString()+" "+query.value(1).toString());
QLabel *Data_operacji = new QLabel(DTData.toString("yyyy-MM-dd HH:mm:ss"));
GbTMP->setLayout(layoutTMP);
layout->addWidget(GbTMP,i++,0,1,1);
}
base->show();
this->setCentralWidget(base);
this->move(((QApplication::desktop()->width()-this->width())/2),((QApplication::desktop()->height()-this->height())/2));
}
To copy to clipboard, switch view to plain text mode
And when there are many records, the window extends beyond the boundary of screen.
How can I "freez" the size of window, and add the verticalslider when the content does not fit in the window?
Bookmarks