crossplatform.ru

Здравствуйте, гость ( Вход | Регистрация )

 
Тема закрытаНачать новую тему
> [РЕШЕНО] QTableView не удаётся показать/скрыть сетку
++Norton++
  опции профиля:
сообщение 26.10.2008, 13:13
Сообщение #1


Студент
*

Группа: Участник
Сообщений: 98
Регистрация: 5.10.2008
Пользователь №: 380

Спасибо сказали: 0 раз(а)




Репутация:   1  


Странно создал в Qt дизайнере форму с двумя TableView и кнопку, которая бы показывала и скрывала сетку. Сетка по умолчанию включена (showGrid = true), однако после компиляции и запуска программы не в одном из TableView сетки нет, просто белые квадраты.
Вот ui_untitled.h:
/********************************************************************************
** Form generated from reading ui file 'untitled.ui'
**
** Created: Sun Oct 26 12:29:03 2008
**      by: Qt User Interface Compiler version 4.3.3
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
********************************************************************************/

#ifndef UI_UNTITLED_H
#define UI_UNTITLED_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QPushButton>
#include <QtGui/QTableView>
#include <QtGui/QWidget>

class Ui_Form
{
public:
    QTableView *tableView;
    QTableView *tableView_2;
    QPushButton *pushButton;

    void setupUi(QWidget *Form)
    {
    if (Form->objectName().isEmpty())
        Form->setObjectName(QString::fromUtf8("Form"));
    Form->resize(580, 305);
    Form->setBaseSize(QSize(5, 5));
    tableView = new QTableView(Form);
    tableView->setObjectName(QString::fromUtf8("tableView"));
    tableView->setGeometry(QRect(20, 70, 256, 192));
    tableView_2 = new QTableView(Form);
    tableView_2->setObjectName(QString::fromUtf8("tableView_2"));
    tableView_2->setGeometry(QRect(300, 70, 256, 192));
    pushButton = new QPushButton(Form);
    pushButton->setObjectName(QString::fromUtf8("pushButton"));
    pushButton->setGeometry(QRect(250, 20, 75, 23));

    retranslateUi(Form);
    QObject::connect(pushButton, SIGNAL(clicked(bool)), tableView, SLOT(setShowGrid(bool)));
    QObject::connect(pushButton, SIGNAL(clicked(bool)), tableView_2, SLOT(setShowGrid(bool)));

    QMetaObject::connectSlotsByName(Form);
    } // setupUi

    void retranslateUi(QWidget *Form)
    {
    Form->setWindowTitle(QApplication::translate("Form", "Form", 0, QApplication::UnicodeUTF8));
    pushButton->setText(QApplication::translate("Form", "PushButton", 0, QApplication::UnicodeUTF8));
    Q_UNUSED(Form);
    } // retranslateUi

};

namespace Ui {
    class Form: public Ui_Form {};
} // namespace Ui

#endif // UI_UNTITLED_H

А вот main.cpp:
#include <QApplication>
#include <QDialog>

#include "ui_untitled.h"

int main(int argc, char *argv[])
{

    QApplication app(argc, argv);
    Ui::Form ui;
    QDialog *dialog = new QDialog;
    ui.setupUi(dialog);
    dialog->show();

    return app.exec();
    }

В чем может быть проблема? Почему сетка не видна?
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение
Litkevich Yuriy
  опции профиля:
сообщение 26.10.2008, 16:56
Сообщение #2


разработчик РЭА
*******

Группа: Сомодератор
Сообщений: 9669
Регистрация: 9.1.2008
Из: Тюмень
Пользователь №: 64

Спасибо сказали: 807 раз(а)




Репутация:   94  


лучшеб ui-файл положил

А как должно переключение происходить? Ты кнопку не тригерную сделал, а простую, сделай тригерную, чтобы аргумент в сигнале менялся.

Уменя все работает, проверять в дизайнере надо сразу, только вместо представлений, виджеты клади, для проверки.
вот пример, и сигнал переключения использован:
ui

<ui version="4.0" >
<class>Form</class>
<widget class="QWidget" name="Form" >
  <property name="geometry" >
   <rect>
    <x>0</x>
    <y>0</y>
    <width>538</width>
    <height>242</height>
   </rect>
  </property>
  <property name="windowTitle" >
   <string>Form</string>
  </property>
  <layout class="QVBoxLayout" >
   <item>
    <layout class="QHBoxLayout" >
     <item>
      <widget class="QTableWidget" name="tableWidget" >
       <row>
        <property name="text" >
         <string>New Row</string>
        </property>
       </row>
       <row>
        <property name="text" >
         <string>New Row</string>
        </property>
       </row>
       <row>
        <property name="text" >
         <string>New Row</string>
        </property>
       </row>
       <column>
        <property name="text" >
         <string>New Column</string>
        </property>
       </column>
       <column>
        <property name="text" >
         <string>New Column</string>
        </property>
       </column>
       <column>
        <property name="text" >
         <string>New Column</string>
        </property>
       </column>
       <column>
        <property name="text" >
         <string>New Column</string>
        </property>
       </column>
      </widget>
     </item>
     <item>
      <widget class="QTableWidget" name="tableWidget_2" >
       <row>
        <property name="text" >
         <string>New Row</string>
        </property>
       </row>
       <row>
        <property name="text" >
         <string>New Row</string>
        </property>
       </row>
       <row>
        <property name="text" >
         <string>New Row</string>
        </property>
       </row>
       <column>
        <property name="text" >
         <string>New Column</string>
        </property>
       </column>
       <column>
        <property name="text" >
         <string>New Column</string>
        </property>
       </column>
       <column>
        <property name="text" >
         <string>New Column</string>
        </property>
       </column>
      </widget>
     </item>
    </layout>
   </item>
   <item>
    <layout class="QHBoxLayout" >
     <item>
      <spacer>
       <property name="orientation" >
        <enum>Qt::Horizontal</enum>
       </property>
       <property name="sizeHint" >
        <size>
         <width>40</width>
         <height>20</height>
        </size>
       </property>
      </spacer>
     </item>
     <item>
      <widget class="QPushButton" name="pushButton" >
       <property name="cursor" >
        <cursorShape>ArrowCursor</cursorShape>
       </property>
       <property name="text" >
        <string>PushButton</string>
       </property>
       <property name="checkable" >
        <bool>true</bool>
       </property>
       <property name="checked" >
        <bool>true</bool>
       </property>
       <property name="default" >
        <bool>true</bool>
       </property>
      </widget>
     </item>
    </layout>
   </item>
  </layout>
</widget>
<resources/>
<connections>
  <connection>
   <sender>pushButton</sender>
   <signal>toggled(bool)</signal>
   <receiver>tableWidget_2</receiver>
   <slot>setShowGrid(bool)</slot>
   <hints>
    <hint type="sourcelabel" >
     <x>461</x>
     <y>217</y>
    </hint>
    <hint type="destinationlabel" >
     <x>448</x>
     <y>173</y>
    </hint>
   </hints>
  </connection>
  <connection>
   <sender>pushButton</sender>
   <signal>toggled(bool)</signal>
   <receiver>tableWidget</receiver>
   <slot>setShowGrid(bool)</slot>
   <hints>
    <hint type="sourcelabel" >
     <x>477</x>
     <y>228</y>
    </hint>
    <hint type="destinationlabel" >
     <x>188</x>
     <y>171</y>
    </hint>
   </hints>
  </connection>
</connections>
</ui>


Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение
++Norton++
  опции профиля:
сообщение 26.10.2008, 22:52
Сообщение #3


Студент
*

Группа: Участник
Сообщений: 98
Регистрация: 5.10.2008
Пользователь №: 380

Спасибо сказали: 0 раз(а)




Репутация:   1  


Спасибо, работает!
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение

Тема закрытаНачать новую тему
Теги
Нет тегов для показа


1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0




RSS Текстовая версия Сейчас: 29.3.2024, 1:13