Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.6.3
-
None
-
Debian GNU/Linux squeeze x86_64, gcc 4.4.4
Description
To demonstrate the bug I wrote a small program.
main.cpp:
#include <QApplication> #include "mainwindowimpl.h" int main(int argc, char ** argv) { QApplication app( argc, argv ); MainWindowImpl mainwnd; mainwnd.show(); return app.exec(); }
mainwindowimpl.cpp:
#include "mainwindowimpl.h" MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f) : QMainWindow(parent, f) { setGeometry(0, 0, 190, 70); left=new QPushButton("left", this); left->setGeometry(10, 40, 80, 20); QObject::connect(left, SIGNAL(pressed()), this, SLOT(ButLeftPressed())); right=new QPushButton("right", this); right->setGeometry(100, 40, 80, 20); QObject::connect(right, SIGNAL(pressed()), this, SLOT(ButRightPressed())); le=new QLineEdit("0123456789", this); le->setGeometry(10, 10, 70, 20); } void MainWindowImpl::ButLeftPressed(void) { int a; a=le->selectionStart(); a--; if (a<0) a=0; le->setSelection(a, 1); } void MainWindowImpl::ButRightPressed(void) { int a; a=le->selectionStart(); a++; if (a>le->text().length()-1) a=le->text().length()-1; le->setSelection(a, 1); }
mainwindowimpl.h:
#ifndef MAINWINDOWIMPL_H #define MAINWINDOWIMPL_H #include <QMainWindow> #include <QPushButton> #include <QLineEdit> class MainWindowImpl : public QMainWindow { Q_OBJECT protected: QPushButton *left, *right; QLineEdit *le; public: MainWindowImpl( QWidget * parent = 0, Qt::WFlags f = 0 ); private slots: void ButLeftPressed(void); void ButRightPressed(void); }; #endif
QLineEdit element has a small width and the text does not appear fully. When you click "left" or "right" button next symbol selected. And this symbol becomes visible on the screen. But not character '0'. Pressing the button "left" lead to that the most visible symbol of the left is '1'. Symbol '0' is selected but not scrolled to correct view. Using the mouse symbol '0 'can be returned.