Home > Mobile >  Dockwidget show and hide
Dockwidget show and hide

Time:09-24

The QDockWidget * dock2=new QDockWidget (this);
The QDockWidget * myWidget2=new QDockWidget;
Dock2 - & gt; SetWidget (myWidget2);

This - & gt; AddDockWidget (Qt: : LeftDockWidgetArea, dock2);
QPushButton * BTN=new QPushButton (this);
BTN - & gt; SetText (tr (" something "));
BTN - & gt; Move (600, 600);
BTN - & gt; Show ();
The connect (BTN, & amp; QAction: : triggered, this dock2 - & gt; Hide ());

The last line error: error: invalid use of void expression
The connect (BTN, & amp; QAction: : triggered, this dock2 - & gt; Hide ())


Pray god give directions!!!!!!!!!!

CodePudding user response:

The QDockWidget * dock2=new QDockWidget (this);
QWidget * widget=new QWidget;
Dock2 - & gt; SetWidget (widget);

.

The connect (BTN, & amp; QPushButton: : clicked, dock2, & amp; QWidget: : hide);

CodePudding user response:

Dock2 - & gt; Hide () to the dock - & gt; Hide, do not add parentheses

CodePudding user response:

Connect the written response function have not seen you,
The connect (BTN, & amp; The QAction: : triggered, this, dockHide ())
 void dockHide () 
{
Dock2 - & gt; Hide ();
}

CodePudding user response:

To the dock - & gt; Hide,

CodePudding user response:

The connect (BTN, & amp; QAction: : triggered, this dock2 - & gt; Hide ());
Instead of
The connect (BTN, & amp; QAction: : triggered, dock, & amp; QDockWidet: : hide);

CodePudding user response:

reference 5 floor clz2012 reply:
connect (BTN, & amp; QAction: : triggered, this dock2 - & gt; Hide ());
Instead of
The connect (BTN, & amp; QAction: : triggered, dock, & amp; QDockWidet: : hide);


Qpushbutton corresponding message will change to qpushbutton yourself some signal, the wrong too much, you suggest to have a look at the first qt signal slot mechanism is related with the help of the document

CodePudding user response:

The connect (BTN, & amp; QAction: : triggered, this dock2 - & gt; Hide ())
Your understanding of the signal channel fundamentally has a problem!
Class QPushButton didn't triggered this signal, you want to put a class BTN QAction signal is ok for you?
Second, this is you define the class instance I guess should be inherited from QMainWindow, should be to hide the slot function, because the base class from QWidget, but you put a slot function dock2 - & gt; Some hide () mean?
You are either so connection
The connect (BTN, SIGNAL (clicked ()), dock2, SLOT (hide ()));
As for why I change to SIGNAL this macro way, not with a function pointer, you can look to the technical documentation, the difference between these two approaches, to highlight: the SIGNAL channel parameters matching limit

CodePudding user response:

The button is the corresponding & amp; QPushButton: : released,,,, was the action & amp; QAction: : triggered.
  •  Tags:  
  • Qt
  • Related