1

Topic: Method call by transmission of object name to function

Kind all time of day.  to cause a method by transmission of object name to function.  the data in the table: Direction_0_1 = new QTableWidget (0, 0, Direction_0); On column button click should change width on data size. In the first case all works: connect (resizeallcol, SIGNAL (clicked ()), this, SLOT (SetAutocol ()));.... void MainWindow:: SetAutocol () {Direction_0_1-> resizeColumnsToContents ();} In the second is not present: connect (resizeallcol, SIGNAL (clicked ()), this, SLOT (SetAutocol (Direction_0_1)));.... void MainWindow:: SetAutocol (QTableWidget *table) {table-> resizeColumnsToContents ();} the Compiler does not swear, but result zero. There are ideas? P.S. I in Qt and With ++ . I learn on the sly. I ask not to abuse strongly.

2

Re: Method call by transmission of object name to function

Hello, Gordon Freeman, you wrote: GF> There are ideas? In SLOT (SetAutocol (Direction_0_1)) Direction_0_1, there should be type, but, apparently, it not a type. It seems to me, it is time to refuse already directives of preprocessor SLOT and SIGNAL. There is a new syntax: QObject:: connect (&a, &Counter::valueChanged, &b, &Counter::setValue); From the main pluses - the compiler begins to swear on errors. More in detail here http://doc.qt.io/qt-5/signalsandslots.html.

3

Re: Method call by transmission of object name to function

S> In SLOT (SetAutocol (Direction_0_1)) Direction_0_1, there should be type, but, apparently, it not a type. No, here  wanted to cause on a signal to cause the slot with certain parameter. So does not quit - slots are caused only with signal parameters (all is possible not all or or generally ). The necessary effect can achieve, making SetDir01 minislot () in which to pull necessary with parameter Direction_0_1. Or, as a variant - to take QSignalMapper.

4

Re: Method call by transmission of object name to function

Hello, Gordon Freeman, you wrote: GF> Kind all time of day. GF> Pytajus to cause a method by transmission of object name to function. Which transmission of optional data is not present in a signal the Author: Igore Date: 18.02.15 GF> Podgruzhaju the data in the table: GF> Direction_0_1 = new QTableWidget (0, 0, Direction_0); better at once it is good to do, use QTableView GF> On column button click should change width on data size. In the first case all works: GF> connect (resizeallcol, SIGNAL (clicked(), this, SLOT (SetAutocol ())); GF> In the second is not present: GF> connect (resizeallcol, SIGNAL (clicked ()), this, SLOT (SetAutocol (Direction_0_1))); the Slot cannot accept more parameters than is emitted in a signal. GF> the compiler does not swear, but result zero. At such syntax the error during execution, in Output will be deduced, and connect false returns GF> P.S. I in Qt and With ++ . I learn on the sly. I ask not to abuse strongly. And what for to you to transfer table as parameter? connect (resizeallcol, SIGNAL (clicked(), this, SLOT (SetAutocolDirection_0_1 ())); void MainWindow:: SetAutocolDirection_0_1 () {Direction_0_1-> resizeColumnsToContents ();}//Or even to unite connect (resizeallcol, &QPushButton::clicked, this, [this] () {Direction_0_1-> resizeColumnsToContents ();});

5

Re: Method call by transmission of object name to function

Hello, Igore, you wrote: I> Hello, Gordon Freeman, you wrote: GF>> Kind all time of day. GF>> Pytajus to cause a method by transmission of object name to function. I> which transmission of optional data is not present in a signal the Author: Igore Date: 18.02.15 GF>> Podgruzhaju the data in the table: GF>> Direction_0_1 = new QTableWidget (0, 0, Direction_0); I> better at once it is good to do, use QTableView GF>> On column button click should change width on data size. In the first case all works: GF>> connect (resizeallcol, SIGNAL (clicked ()), this, SLOT (SetAutocol ())); GF>> In the second is not present: GF>> connect (resizeallcol, SIGNAL (clicked ()), this, SLOT (SetAutocol (Direction_0_1))); I> the Slot cannot accept more parameters than is emitted in a signal. GF>> the compiler does not swear, but result zero. I> at such syntax the error during execution, in Output will be deduced, and connect false returns GF>> P.S. I in Qt and With ++ . I learn on the sly. I ask not to abuse strongly. I> and what for to you to transfer table as parameter? I> I> connect (resizeallcol, SIGNAL (clicked ()), this, SLOT (SetAutocolDirection_0_1 ())); I> void MainWindow:: SetAutocolDirection_0_1 () I> {I> Direction_0_1-> resizeColumnsToContents (); I>} I>//Or even to unite I> connect (resizeallcol, &QPushButton::clicked, this, [this] () {Direction_0_1-> resizeColumnsToContents ();}); I> Hello. Thanks all for answers. The program should .csv files (which can be more than dozen) in tables. Then in tables all to be filtered (to delete unnecessary etc.) . Since the amount of tables is not fixed, I tried to write general-purpose -, which  the necessary operations by transmission to it of the pointer on the table as parameter. If I cause - without parameter, thus in its body specifying the table (the minislot as specified 13) all plows: connect (resizeallcol, SIGNAL (clicked(), this, SLOT (SetAutocol ())); the Problem that then on each table it is necessary to write separate -.

6

Re: Method call by transmission of object name to function

Hello, Gordon Freeman, you wrote: GF> Hello, Igore, you wrote: I>> Hello, Gordon Freeman, you wrote: GF>>> Kind all time of day. GF>>> Pytajus to cause a method by transmission of object name to function. I>> which transmission of optional data is not present in a signal the Author: Igore Date: 18.02.15 GF>>> Podgruzhaju the data in the table: GF>>> Direction_0_1 = new QTableWidget (0, 0, Direction_0); I>> better at once it is good to do, use QTableView GF>>> On column button click should change width on data size. In the first case all works: GF>>> connect (resizeallcol, SIGNAL (clicked ()), this, SLOT (SetAutocol ())); GF>>> In the second is not present: GF>>> connect (resizeallcol, SIGNAL (clicked ()), this, SLOT (SetAutocol (Direction_0_1))); I>> the Slot cannot accept more parameters than is emitted in a signal. GF>>> the compiler does not swear, but result zero. I>> At such syntax the error during execution, in Output will be deduced, and connect false returns GF>>> P.S. I in Qt and With ++ . I learn on the sly. I ask not to abuse strongly. I>> and what for to you to transfer table as parameter? I>> I>> connect (resizeallcol, SIGNAL (clicked ()), this, SLOT (SetAutocolDirection_0_1 ())); I>> void MainWindow:: SetAutocolDirection_0_1 () I>> {I>> Direction_0_1-> resizeColumnsToContents (); I>>} I>>//Or even to unite I>> connect (resizeallcol, &QPushButton::clicked, this, [this] () {Direction_0_1-> resizeColumnsToContents ();}); I>> GF> Hello. GF> thanks all for answers. GF> the program should .csv files (which can be more than dozen) in tables. Then in tables all to be filtered (to delete unnecessary etc.) . GF> Since the amount of tables is not fixed, I tried to write general-purpose -, which  the necessary operations by transmission to it of the pointer on the table as parameter. GF> if I cause - without parameter, thus in its body specifying the table (the minislot as specified 13) all plows: connect (resizeallcol, SIGNAL (clicked(), this, SLOT (SetAutocol ())); GF> the Problem that then on each table it is necessary to write separate -. And a small chest simply : connect (resizeallcol, SIGNAL (clicked ()), Direction_0_1, SLOT (resizeColumnsToContents ()));

7

Re: Method call by transmission of object name to function

8

Re: Method call by transmission of object name to function

Hello, Igore, you wrote: GF>> Podgruzhaju the data in the table: GF>> Direction_0_1 = new QTableWidget (0, 0, Direction_0); I> better at once it is good to do, use QTableView And in what a problem of application QTableWidget? Here: http://www.cyberforum.ru/qt/thread238089.html write that if at us less than approximately 500 lines it is more convenient to apply QTableWidget (provides more convenient API). Here: http://www.qtforum.org/article/25107/di … eview.html write that QTableView it is more preferable by operation from a DB when there is a table with a considerable quantity of records - the variant with QTableView benefits for the account of application Model/View of architecture. As I understood, the general-purpose decision is not present. However, studying source codes Qt and noting that QTableWidget - the successor from QTableView: class Q_WIDGETS_EXPORT QTableWidget: public QTableView {Q_OBJECT...}; I would be afraid unambiguously to recommend TC passage on QTableView from QTableWidget.

9

Re: Method call by transmission of object name to function

Hello, AlexGin, you wrote: QTableWidget  uses the same model/view, that is it is simple  on QTableView.

10

Re: Method call by transmission of object name to function

Hello, AlexGin, you wrote: GF>>> Podgruzhaju the data in the table: GF>>> Direction_0_1 = new QTableWidget (0, 0, Direction_0); I>> better at once it is good to do, use QTableView AG> And in what a problem of application QTableWidget? Yes in what, it is simple at usage QTableView at you there will be a model (separately), and further as usual happens, QTableView migrates in QTreeView, or it is necessary QItemSelectionModel on some View or separate delegates for columns or QProxyModel is necessary, in general  when hour Ha comes better that you had a model and QTableView, than only QTableWidget where all is mixed.

11

Re: Method call by transmission of object name to function

Hello, Gordon Freeman, you wrote: GF> connect (resizeallcol, SIGNAL (clicked ()), this, SLOT (SetAutocol (Direction_0_1))); GF>.... GF> void MainWindow:: SetAutocol (QTableWidget *table) GF> {GF> table-> resizeColumnsToContents (); GF>} GF> the Compiler does not swear, but result zero. GF> there are ideas? If I correctly understood that you want, a lambda your friend: connect (resizeallcol, &QClass::clicked, [this] {this-> SetAutocol (Direction_0_1);}));