Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, June 2007
QTcpSocket slows down


Message 1 in thread

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
if I execute the following program, I see
(look at the output, following the code)
that every loop takes longer.
Of course, it may be, that it is not "every" loop, but
just one of the 1000 loops I qDebug...


- ---- Code ---------
#include <QCoreApplication>
#include <QStringList>
#include <QtDebug>
#include <QTime>
#include <QTcpSocket>


int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    QStringList lstArgs = app.arguments();
    qDebug() << lstArgs.at(0) << " build " << __DATE__ << " " << __TIME__;

    QTime timer;
    timer.start();
    for (int nPort = 1; nPort < 65000; nPort++)
    {
        QTcpSocket socket;
        socket.connectToHost("127.0.0.1", nPort);
        if (socket.waitForConnected(30) == true)
            qDebug() << "open:" << nPort << " ";
        if (nPort % 1000 == 0)
            qDebug() << "to " << nPort << " " << timer.restart() << " ms";
    } // for

    return 0;
}
- ------ end of code ---------


I removed all "open" lines
- ------- begin of output -------
to  1000   227  ms
to  2000   294  ms
to  3000   375  ms
to  4000   455  ms
to  5000   557  ms
to  6000   650  ms
to  7000   784  ms
to  8000   963  ms
to  9000   1164  ms
to  10000   1397  ms
to  11000   1657  ms
to  12000   1900  ms
to  13000   2166  ms
to  14000   2482  ms
to  15000   2743  ms
to  16000   2970  ms
to  17000   3172  ms
to  18000   3360  ms
to  19000   3565  ms
to  20000   3710  ms
to  21000   3908  ms
to  22000   4105  ms
to  23000   4497  ms
to  24000   4472  ms
to  25000   5285  ms
to  26000   5106  ms
to  27000   5029  ms
to  28000   5199  ms
to  29000   5500  ms
to  30000   5707  ms
to  31000   6037  ms
to  32000   6139  ms
to  33000   6101  ms
to  34000   6348  ms
to  35000   6563  ms
to  36000   6967  ms
to  37000   6785  ms
to  38000   6886  ms
to  39000   7596  ms
to  40000   7350  ms
to  41000   7613  ms
to  42000   7601  ms
to  43000   7701  ms
to  44000   7876  ms
to  45000   8148  ms
to  46000   8469  ms
to  47000   8835  ms
to  48000   8960  ms
to  49000   8939  ms
to  50000   8886  ms
to  51000   9058  ms
to  52000   9269  ms
to  53000   9538  ms
to  54000   10134  ms
to  55000   9980  ms
to  56000   10001  ms
to  57000   10294  ms
to  58000   10291  ms
to  59000   10496  ms
to  60000   10862  ms
to  61000   11166  ms
to  62000   10977  ms
to  63000   11274  ms
to  64000   11351  ms
- --------- END of output ----------

What am I doing wrong ?


Help,
Andreas

- --

In war and programming, all is allowed. But war is not about who is
right, it is about who is left.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGf8Hjj+rlWl9yTkcRAlcmAKDxsAWNh0oq4NzfbeF6uGoP47rvPQCfVTPK
8ni2KgsfiUEjyFlTty36h3A=
=HDsa
-----END PGP SIGNATURE-----

--
 [ signature omitted ] 

Message 2 in thread

Hello,
how can i achieve that a selection "by code" looks the same as a selection 
made by the user? By default a selected item or row (depending on 
SelectionBehavior) by a user os highlighted blue. When a select via 
QTableVIew::selectRow() or QSelectionModel::select() the selected item/row 
is light gray and hardly visible. Am i doing something wrong or am i 
forgetting something? I would like both ways to have the same color so its 
not visible to the user wether he selected an item or it got selected by the 
program.

I am having another problem with selections. I have a QTableView that shows 
only one row. When i execute QTableView::selectRow(0) the row gets selected 
but also the horizontal header seems to be selected. It look sliek its being 
pressed. If the table has more than one row this doesnt occurr.
I am using Qt 4.2 open source version on WinXP VS 2003.

Thanks for yoru help, i really appreciate it
Bastian

_________________________________________________________________
Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit 
Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu! 
http://desktop.msn.de/ Jetzt gratis downloaden!

--
 [ signature omitted ] 

Message 3 in thread

> QTableVIew::selectRow() or QSelectionModel::select() the selected
item/row
> is light gray and hardly visible. Am i doing something wrong or am i
> forgetting something? I would like both ways to have the same color so
its
> not visible to the user wether he selected an item or it got selected
by
> the
> program.

You're probably mixing up current item and selected item(s).
You should change the current item, not only the selection.

Cheers,
Peter

--
 [ signature omitted ] 

Message 4 in thread

>From: "Peter Prade" <prade@xxxxxxxxxxx>
>To: <qt-interest@xxxxxxxxxxxxx>
>Subject: RE: QAbstractItemView and selection
>Date: Mon, 25 Jun 2007 18:40:04 +0200
>
> > QTableVIew::selectRow() or QSelectionModel::select() the selected
>item/row
> > is light gray and hardly visible. Am i doing something wrong or am i
> > forgetting something? I would like both ways to have the same color so
>its
> > not visible to the user wether he selected an item or it got selected
>by
> > the
> > program.
>
>You're probably mixing up current item and selected item(s).
>You should change the current item, not only the selection.
>
>Cheers,
>Peter

Hi Peter,
i actually thought that was what i had done first, envertheless i tried it 
again:
myTableView->selectionModel()->setCurrentIndex(myModel->index(0,0),QItemSelectionModel::SelectCurrent);

This works even worse. My header still seems to be pressed (or selected 
somehow), which i cant even reproduce by user interaction. I Cant select or 
mark or press the header. Other problem is that now only my item (0,0) of 
the table is "gray", not the whole row. setCurrentItem ignores the selection 
behavior.
The documentation says that the current item is kind of independant from the 
selection and is for userinteraction with the keyboard. Im nto sure that is 
what i want :) I just want the row to look like the user selected it with 
the mouse (kind of a default selection as one row, and only one, has to be 
selected all the time).
I hope you remember what my problem was about as my last posting was 2 days 
ago.

I am thankfull for any hint!!!
Bastian

_________________________________________________________________
Haben Spinnen Ohren? Finden Sie es heraus ? mit dem MSN Suche Superquiz via  
http://www.msn-superquiz.de  Jetzt mitmachen und gewinnen!

--
 [ signature omitted ] 

Message 5 in thread

Hi again, Bastian.

It sounds like your table view has lost focus (can you use the keyboard
to change the selected line, after you set your selection
programmatically?)

Try to also give the focus back to the view. tableView->setFocus()

No idea about the "pressed" table headers though.

Oh and did you check QAbstractItemView::setSelectionBehavior ?

Cheers,
Peter

Bastian Dittmar wrote:
> Hi Peter,
> i actually thought that was what i had done first, envertheless i
tried it
> again:
> myTableView->selectionModel()->setCurrentIndex(myModel-
> >index(0,0),QItemSelectionModel::SelectCurrent);
> 
> This works even worse. My header still seems to be pressed (or
selected
> somehow), which i cant even reproduce by user interaction. I Cant
select
> or
> mark or press the header. Other problem is that now only my item (0,0)
of
> the table is "gray", not the whole row. setCurrentItem ignores the
> selection
> behavior.
> The documentation says that the current item is kind of independant
from
> the
> selection and is for userinteraction with the keyboard. Im nto sure
that
> is
> what i want :) I just want the row to look like the user selected it
with
> the mouse (kind of a default selection as one row, and only one, has
to be
> selected all the time).
> I hope you remember what my problem was about as my last posting was 2
> days
> ago.
> 
> I am thankfull for any hint!!!
> Bastian

--
 [ signature omitted ] 

Message 6 in thread

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Does really noone at all knows anything about this ?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGhQQFj+rlWl9yTkcRAn5xAKCFkc8wfHEuEjxgWNaSvINnR+xY/QCgkgdB
A540yp78bwlAlx1LLN5n9L8=
=4oVE
-----END PGP SIGNATURE-----

--
 [ signature omitted ]