You are not logged in.

1

Wednesday, May 16th 2012, 10:46pm

create new widget with signal

Hi,
it's me again
i have question :
is it possible to create widget with signal:
i have function in my program that draw circle (when i clic to button it draw to me circle)
and i want each circle be in new widget
for that i think to add in the function draw circle and signal to create new widget
but i want to know befor is that possible or no
thanks for repling with any reply and i am sorry for my bad english

2

Thursday, May 17th 2012, 8:49am

yes, it's possible.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

3

Friday, May 18th 2012, 10:05pm

Thtanks,
if you have time and you know link that make like as i want
please put it

4

Friday, May 18th 2012, 10:50pm

connect signal http://qt-project.org/doc/qt-4.8/qabstra…on.html#clicked to your slot that makes a widget which draws a circle
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

5

Sunday, May 20th 2012, 1:38pm

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 MainWindow::MainWindow()  
    {  
        this->setBaseSize(1500,1500);  
        my_calsseWidget = new my_classe(this);  
          
        setCentralWidget(my_calsseWidget);  
        createModel();  
         
        createDockWidget();  
          connect(my_calsseWidget, SIGNAL(add_camSignal()), this, SLOT(createwidget()));    
    }  
    void MainWindow::createwidget()    
    {    
        QWidget * my_widget = new QWidget(this);    
       my_widget->show();  
     
    }   

but i do not see the new widget

6

Sunday, May 20th 2012, 2:23pm

because you gave it a parent so it will not be a new window, it will be embedded in the parent. Qt parenting rules '101'.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

7

Sunday, May 20th 2012, 4:38pm

no, i do not think is that the problem because even if i make
QWidget * my_widget = new QWidget();
i do not see it

i think i must create list of pointer of widget

8

Monday, May 21st 2012, 12:28pm

this WILL work

QWidget * my_widget = new QWidget();
my_widget->show();
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

9

Monday, May 21st 2012, 8:44pm

thanks
yes it work but if i add

Source code

1
2
3
4
5
6
7
8
9
10
11
void MainWindow::createwidget()
{
	    QWidget *camwidget = new QWidget();  
		camwidget->setGeometry(QRect(0, 0, 98, 28));
		
	listwidget.push_back(camwidget);
		for(int i=0;i<listwidget.size();i++)
	{
	   	 listwidget[i]->show(); 
       }
}

but it is empty

i want to add the same dockwidget and their button in the mainwindow to my new widget
is there an idea to make that

10

Tuesday, May 22nd 2012, 8:17am

instead of 'new QWidget', just do 'new WhateverWidgetYouWant'.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

11

Tuesday, May 22nd 2012, 8:54am

"instead of 'new QWidget', just do 'new WhateverWidgetYouWant'. "
that is my problem i can"t find idea to do that
because the dokcwidget is created in mainwindow and i want create it too in the new widget(the same)

12

Tuesday, May 22nd 2012, 1:08pm

QDockWidget is just a container that does the docking.


If you have your own widget that does something special, e.g. MyWidget, and you want to make one these and dock it somewhere, you would doit a bit like this:

Source code

1
2
3
4
5
6
QDockWidget* dock = new QDockWidget;
MyWidget* mywidget = new MyWidget;
dock->setWidget(mywidget);

 //  [url]http://qt-project.org/doc/qt-4.8/qmainwindow.html#addDockWidget[/url]
your_mainwindow->addDockWidget(..., dock);
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

13

Tuesday, May 22nd 2012, 10:02pm

Hi
sorry the idea rest not clear for me
i will expalin to you how i create my dock
i haveon my code like that

Source code

1
2
3
4
5
6
MainWindow::MainWindow()
{
   my_class = new My_Class(this);
    setCentralWidget(my_class);
	    createDockWidget();
}

and in the createDockwidget
i make like that

Source code

1
2
3
4
5
6
7
8
9
10
11
void MainWindow::createDockWidget()
{
 dockWidget_1 = new QDockWidget(this);
            dockWidget_1->setObjectName(QString::fromUtf8("dockWidget_1"));
          dockWidget_1->setWidget(dockWidgetContents_8);
            addDockWidget(static_cast<Qt::DockWidgetArea>(2), dockWidget_1);
          dockWidget_1->setWindowTitle(QApplication::translate("MainWindow", " ", 0, QApplication::UnicodeUTF8));
           dockWidget_1->setFloating(false);
           page_1 = new QWidget(this);
            page_1->setObjectName(QString::fromUtf8("page_1"));
            page_1->setGeometry(QRect(0, 0, 98, 28));

i use this her because thy are in the mainwindow
i tried to make in my createwidget like that

Source code

1
2
3
4
5
6
7
8
9
10
11
void MainWindow::createwidget()
{
	    QWidget *camwidget = new QWidget();  
		camwidget->setGeometry(QRect(0, 0, 98, 28));
		createDockWidget();
	listwidget.push_back(camwidget);
		for(int i=0;i<listwidget.size();i++)
	{
	   	 listwidget[i]->show(); 
       }
}

but it add to me another dockwidget in the mainwindow not in my new widget

14

Wednesday, May 23rd 2012, 12:43pm

dock widgets can ONLY go in the mainwindow.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

15

Wednesday, May 23rd 2012, 1:46pm

"dock widgets can ONLY go in the mainwindow. "
is that mean i can't mkae dock widget in my new widgets ?
if yes
can i just related the dock widget created in the mainwindow with the new widget?

16

Wednesday, May 23rd 2012, 7:42pm

"is that mean i can't mkae dock widget in my new widgets ?"
yes.

"can i just related the dock widget created in the mainwindow with the new widget?"
If there is already a dock widget, you can change the contents (what is inside the dock widget) at any time that you like.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

17

Wednesday, May 23rd 2012, 10:26pm

"If there is already a dock widget, you can change the contents (what is inside the dock widget) at any time that you like. "
i do not want change the content of the dock but i want related it to my new widget

18

Wednesday, May 23rd 2012, 10:35pm

doesnt make sense.

you cant 'relate' a dock widget to anything except for that which it holds. if a dock widget doesn't hold anything, it isn't related to anything (except for parent).
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

19

Wednesday, May 23rd 2012, 11:02pm

Ok
i have then another question (because i just want an idea )

i will explain to you what i have and what want and i need to help me if you can by an idea to de tat (not code )

in my class "My_Class" i create scene and i rendred it using camera in viewport (the dimension of the viewport is all the window ) all that in my function "paint" and i make "My_Class" as central window i create after that dockwidget,button......
i want now add new camera(iahve not problème in that) and render my scene by the new camera BUT in NEW window(for that when i add camera i create new widget) my problem is her
for exemple to create viewport to the proncipal camera

Source code

1
2
3
4
5
6
7
8
9
10
void My_Class::createViewports(void)
{
  	  // Create one viewport, entire window
    Ogre::Viewport* vp = mWindow->addViewport(mCamera);
    vp->setBackgroundColour(Ogre::ColourValue(0,0,0));

    // Alter the camera aspect ratio to match the viewport
    mCamera->setAspectRatio(
        Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
}

look there is "mcamera"(when i want render the scene by the new camera i think to send it by signal to this function and "mcamera" be "newcam" BUT there is also " mWindow-" wich if i create new cam will be not m window but my new widget

have you an idea or advice to make what i want
(if you do not understand what i want i can more explain to you )
thanks for repling

20

Thursday, May 24th 2012, 12:30pm

Source code

1
2
3
4
5
6
7
8
9
10
void My_Class::createViewports(WindowClass* window, CameraClass* camera)
{
  	  // Create one viewport, entire window
    Ogre::Viewport* vp = window->addViewport(camera);
    vp->setBackgroundColour(Ogre::ColourValue(0,0,0));

    // Alter the camera aspect ratio to match the viewport
    camera->setAspectRatio(
        Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
}

??
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar threads