QComboBox doing weird things on first show
-
[quote author="EukeSnud" date="1309855086"]But you did have problems with Windows 7 aero theme[/quote]
No, it works on both Win 7 themes. I also played with and without layouts, but I didn't reproduce your bug. -
My combobox won't cause trouble unless I have more than 3 entries in it...
-
Just added a combobox to my main widget and filled it with 100 entries. No problems with this one ...
-
Might it be a problem with my QDialog? Let me post a small project containing a slim version of it...
qdbdialog.h
@#ifndef QDBDIALOG_H
#define QDBDIALOG_H#include <QDialog>
#include <QString>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QCheckBox>
#include <QtGui/QComboBox>
#include <QtGui/QDialogButtonBox>class QDbDialog : public QDialog
{
Q_OBJECT
public:
QDbDialog(QWidget * parent = 0, Qt::WindowFlags f = 0);
QDbDialog(QString *usr, QString *pwd, QString *dsn);
~QDbDialog();public slots:
void closeWithOk();
void closeWithCancel();
void closeWithB(bool b);private:
QString *user;
QString *passwd;
QString *dstn;QLabel *lblUsr; QLabel *lblPwd; QLabel *lblDsn; QLineEdit *txtUsr; QLineEdit *txtPwd; QComboBox *cbDsn; QDialogButtonBox *btnBox;
};
#endif@qdbdialog.cpp
@#include "qdbdialog.h"
#include <QLayout>QDbDialog::QDbDialog(QWidget * parent, Qt::WindowFlags f) :
QDialog(parent,f),user(new QString("user")),passwd(new QString("pwd")),dstn(new QString("dsn")) {
}QDbDialog::QDbDialog(QString *usr, QString *pwd, QString *dsn) : user(usr),passwd(pwd),dstn(dsn) {
lblUsr = new QLabel("&Username:");
txtUsr = new QLineEdit;
lblUsr->setBuddy(txtUsr);lblPwd = new QLabel("&Password:"); txtPwd = new QLineEdit;
txtPwd->setEchoMode(QLineEdit::Password);
lblPwd->setBuddy(txtPwd);lblDsn = new QLabel("&ODBC-Datasource");
cbDsn = new QComboBox();
lblDsn->setBuddy(cbDsn);QStringList dsnlist;
for (int i=0;i<100;i++) {
dsnlist.push_back("TEST" + QString::number(i+1));
}dsnlist.sort();
cbDsn->addItems(dsnlist);btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(btnBox,SIGNAL(accepted()),this,SLOT(closeWithOk()));
connect(btnBox,SIGNAL(rejected()),this,SLOT(reject()));QGridLayout *mainLayout = new QGridLayout();
mainLayout->addWidget(lblUsr,0,0);
mainLayout->addWidget(txtUsr,0,1);
mainLayout->addWidget(lblPwd,1,0);
mainLayout->addWidget(txtPwd,1,1);
mainLayout->addWidget(lblDsn,2,0);
mainLayout->addWidget(cbDsn,2,1);
mainLayout->addWidget(btnBox,4,0,1,2);setLayout(mainLayout);
}QDbDialog::~QDbDialog() {
}
void QDbDialog::closeWithOk() {
*user = txtUsr->text();
*passwd = txtPwd->text();
*dstn = cbDsn->currentText();
done(QDialog::Accepted);
}void QDbDialog::closeWithCancel() {
done(QDialog::Rejected);
}void QDbDialog::closeWithB(bool b) {
if (b)
done(QDialog::Accepted);
else
done(QDialog::Rejected);
}@main.cpp
@#include "qdbdialog.h"
#include <QtGui/QApplication>int main(int argc, char *argv[])
{
QApplication a(argc, argv);QString usr;
QString pwd;
QString dsn;QDbDialog dbdiag(&usr,&pwd,&dsn);
dbdiag.exec();return a.exec();
}
@ -
I tested your posted code both with Win7 Aero theme and with Win7 Basic, but I could not replicate your problem.
[quote author="EukeSnud" date="1309849910"]But then the entries suddenly move to the top[/quote]
This happens without you doing anything? -
[quote author="cincirin" date="1309861645"]I tested your posted code both with Win7 Aero theme and with Win7 Basic, but I could not replicate your problem.
[quote author="EukeSnud" date="1309849910"]But then the entries suddenly move to the top[/quote]
This happens without you doing anything?
[/quote]Yes, the entries are in the right spot for less than a second and then jump to the top. (As shown on the screens)
-
[quote author="EukeSnud" date="1309856718"]Just added a combobox to my main widget and filled it with 100 entries. No problems with this one ... [/quote]
From what I understand, it is part of the code you posted, and you have no problems.
Are you sure that when you fill other combo box with ODBC drivers, you don't call other functions ? -
The code I posted is of a dialog window which can be executed as shown in main.cpp and this code causes the combobox on my dialog to perform the strange steps described...
However the dialog is part of a greater project and because I didn't want to post all of its source files I created this slim project above just executing my custom dialog.What I meant was, that I added a combobox to the main widget in my greater project and filled it with 100 entries. This combobox does not show the strange behaviour like the one mentioned in the code above!
-
Sorry, I can not replicate your problem with posted code on Win 7 (with both Aero & Basic themes). Maybe someone else can get an idea of what can happen.
-
I just tried it on another Win7 machine in the office and it worked just fine, so the problem seems to be bound to my local machine. But what could it be????
-
Maybe DPI ? ... or something else specific to your Win7 configuration