You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

panzar

Beginner

  • "panzar" started this thread

Posts: 10

Location: Skovde, Sweden.

  • Send private message

1

Thursday, April 14th 2005, 10:21am

KMultiTabBar and KParts::MainWindow

Hi,

I'm wondering how I'm supposed to do the layout for my application. The application consists of a KParts::MainWindow and a KMultiTabBar to the left:



The toolbar is overlapping the tabbar and the kpart. The code looks like this now:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
kavr::kavr()
    : KParts::MainWindow(0, "kavr")
{
 
    m_mapper = new QSignalMapper(this);
 
    // Create a KMultiTabBar.   
    m_tabBar = new KMultiTabBar(KMultiTabBar::Vertical, this);
    m_tabBar->setPosition(KMultiTabBar::Left);
 
 
    // Create a tab.    
    m_tabBar->appendTab(0, -2, "Files");
    QWidget *tab = m_tabBar->tab(-2);
    m_tabBar->showActiveTabTexts(true);
    m_tabBar->setTab(-2, true);
 
 
    // Set the shell's ui file.
    setXMLFile("kavr_shell.rc");
 
    // Setup our actions.
    setupActions();
 
    // Load the appropriate library.
    KLibFactory *factory = KLibLoader::self()->factory("libkyzispart");
 
    // Cast the KPart to a KtextEditor::Editor.
    m_part = static_cast<KTextEditor::Editor*>(factory->create(this, "ktexteditor_part", "KTextEditor::Editor") );
 
    // Add a layout to the mainwindow.  
    m_layout = new QHBoxLayout(this);
    m_layout->add(m_tabBar);
    m_layout->add(m_part->widget() );
    m_layout->activate();// If the part was created successfully...
 
    if (m_part)
    {
        // Tell the mainwindow that this is the mainwidget.
        setCentralWidget(m_part->widget() );
 
        // Integrate the part's GUI with our mainwindow.
        createGUI(m_part);
    }


Any ideas how to arrange the layout?

Thanks in advance,

Per

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Thursday, April 14th 2005, 4:00pm

Usually MainWindows already have a layout.

Try creating a QFrame, using it as the CentralWidget and add the two other widgets and your layout to the frame

Cheers,
_
Qt/KDE Developer
Debian User

panzar

Beginner

  • "panzar" started this thread

Posts: 10

Location: Skovde, Sweden.

  • Send private message

3

Friday, April 15th 2005, 7:28am

Quoted

Originally posted by anda_skoa
Usually MainWindows already have a layout.

Try creating a QFrame, using it as the CentralWidget and add the two other widgets and your layout to the frame

Cheers,
_


Thanks for the tip, however I can't get it to work properly.



I tried to do what you suggested, it's possible that I misunderstood you though:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
kavr::kavr() 
	: KParts::MainWindow(0, "kavr")
{
	
	m_mapper = new QSignalMapper(this);

	m_mainFrame = new QFrame(this);
	
	// Tell the mainwindow that this is the mainwidget.
	setCentralWidget(m_mainFrame);
	
	// Set the shell's ui file.
	setXMLFile("kavr_shell.rc");

	// Setup our actions.
	setupActions();

	// Load the appropriate library.
	KLibFactory *factory = KLibLoader::self()->factory("libkyzispart");

	// Cast the KPart to a KtextEditor::Editor.
	m_part = static_cast<KTextEditor::Editor*>(factory->create(this, "ktexteditor_part", "KTextEditor::Editor") );


	if (m_part) 
	{
	
			
	// Create a KMultiTabBar.	
	m_tabBar = new KMultiTabBar(KMultiTabBar::Vertical, this->centralWidget() );
	m_tabBar->setPosition(KMultiTabBar::Left);

	// Create a tab.	
	m_tabBar->appendTab(0, -2, "Files");
	QWidget *tab = m_tabBar->tab(-2);
	m_tabBar->showActiveTabTexts(true);
	m_tabBar->setTab(-2, true);
		
	// Add a layout to the mainwindow.	
	m_layout = new QHBoxLayout(m_mainFrame);
	m_layout->add(m_tabBar);
	m_layout->add(m_part->widget() );
	m_layout->activate();// If the part was created successfully...
		
		
	// Integrate the part's GUI with our mainwindow.
	createGUI(m_part);
	
	}


Thanks again,

Per

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

4

Friday, April 15th 2005, 9:30am

I think the problem is that you pass "this" as the parent to the factory.

You could reparent m_part->widget() to m_mainFrame

Cheers,
_
Qt/KDE Developer
Debian User

panzar

Beginner

  • "panzar" started this thread

Posts: 10

Location: Skovde, Sweden.

  • Send private message

5

Friday, April 15th 2005, 11:58am

Quoted

Originally posted by anda_skoa
I think the problem is that you pass "this" as the parent to the factory.

You could reparent m_part->widget() to m_mainFrame

Cheers,
_


Of course! Thanks a lot :)
Looks great now:



Thanks again,

Per